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 Plugins/Workflows

Usage of Resx file in D365 Plugins/Workflows:

Most of the times, we use fetchxml queries in the plugins and workflows to retrieve the entity data and we directly hardcode these queries in the retrieve methods. Instead we can use Resources file(.resx) to store all the fetchxml in common file and use it wherever it is required. This helps in maintaining the code and also promotes reusability.

Creation of Resx File:

Below is the sample Plugin project I have created to explain the usage of Resx file.







Once the project is created, add new resource file named as "FetchXML.resx" as shown below.














After the file is added to the project, open the "FetchXML.resx" file from solution explorer.









Add the Name and Fetchxml under the value as shown below. For filter conditions, you can use some placeholders(eg: {EmailAddress}) and replace after you retrieve the Fetchxml string from resource file.








Once added save this file.

In the plugin code, fetchxml  can be retrieved from resource file using the following code.





Sample code snippet for retrieving the fetchxml from resource file and using in the plugin.

 // Retrieve the AccountFetchXML from Resource file.  
 string accountFetchXML = TestPlugin.FetchXML.ResourceManager.GetString("GetAccountbyEmail", CultureInfo.InvariantCulture);  
   
 // Replace condition values.  
 accountFetchXML = accountFetchXML.Replace("{EmailAddress}", email);  
   
 // Execute the fetchxml query.  
  EntityCollection accountCollection = service.RetrieveMultiple(new FetchExpression(accountFetchXML));  

Comments

Popular posts from this blog

Using Shared libraries in D365 CE Plugin

Ribbon debug/Command checker tool