Hide Headers, Commandbar, Tabs in D365 Forms

Image
There are options available to hide Command Bar, Header part and Tabs.  Below is the screenshot which highlights these areas for your understandings. let formContext = Xrm.Page ; or let formContext = executionContext.getFormContext(); // Hide Header part formContext.ui.headerSection.setBodyVisible(false);   //Hide Command bar formContext.ui.headerSection.setCommandBarVisible(false);   // Hide Tabs formContext.ui.headerSection.setTabNavigatorVisible(false); After all are hidden,

Using Resx file in D365 JS

Most of the times, we have validation or error messages to be shown to user during client side validations in D365. We directly hardcode these message in the JS functions. Instead we can use Resources file(.resx) to store all the messages in common file and use it wherever it is required.  This helps in maintaining the code and also promotes reusability. 

This file format is also supported in web resources.

Creation of Resource file:

In visual studio, resource file can be directly created as shown below.








Add the validations message as shown below and save the file(eg:UserValidationMessages). You can add as many messages you want.

Open D365 web resource and upload this file by selecting Type as 'String(RESX)' as shown below.


Below is the sample code to retrieve the messages from resource file.
  var emailValidationMessage = Xrm.Utility.getResourceString("new_UserValidationMessages.resx", "AccountEmailAddressValidationMessage");  



The resource file can be updated anytime by downloading the file from webresource url as shown below.


Save the file. 

Open in Visual studio and update the message.

This file can be updated back to web resource as shown below.


This approach can also be used in multi-language supported applications where message should be shown based on the user selected language.

Comments

Popular posts from this blog

Convert datetime to user local in D365 Plugins

Using Resx file in D365 Plugins/Workflows

Run Power automate under modifying user context