Ribbon debug/Command checker tool

Image
Background: Usually when something goes wrong in the button visibility or to find out the rules, actions(js) being used in the ribbon button, we go and find either in the ribbondiffxml or through ribbon workbench. This is a time taking process.  Solution: Now there is a built-in tool called 'Command Checker' available. Using this tool, we can easily troubleshoot the button visibility related issues in home page grid, entity form, sub grid and global command bar as well.  To use/enable this tool, pass "ribbondebug=true" parameter in the url. Example, if you want to troubleshoot some button in Account form, below is the url,  https://trial.crm5.dynamics.com/main.aspx?appid=4db5bcb8-675b-ec11-8f8f-002248599a15&pagetype=entityrecord&etn=account&id=83883308-7ad5-ea11-a813-000d3a33f3b4 &ribbondebug=true This will enable the command bar in 3 places. 1. In the header's right side 2. In the Form command bar 3. If the form has any sub grids. Co...

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

Convert datetime to user local in D365 Plugins

Show/Hide ribbon button based on the selected view in the D365 subgrid

Ribbon debug/Command checker tool