D365 CE: Get Logged in User’s Security Roles using JavaScript

Many times we come across requirements such as show/hide ribbon buttons based on logged in user's security role. Earlier, we used to get security roles of logged in user at client side using Xrm.Utility.getGlobalContext().userSettings.securityRoles which used to return array of GUID value of each security role. Now that it's deprecated, we can use Xrm.Utility.getGlobalContext().userSettings.roles which … Continue reading D365 CE: Get Logged in User’s Security Roles using JavaScript

D365 CE: Show/Hide and Enable/Disable same field placed in multiple tabs using JavaScript

We often put the same fields in different tabs based on business requirements. To Hide/Show such fields we need to use below script: var formContext = executionContext.getFormContext(); formContext.getAttribute("fieldName").controls.forEach( function (control, i) { ¬† ¬† ¬†control.setVisible(false/true); }); Similarly, to Enable/Disable such fields we need to use below script: formContext.getAttribute("fieldName").controls.forEach( function (control, i) { control.setDisabled(false/true); }); Without … Continue reading D365 CE: Show/Hide and Enable/Disable same field placed in multiple tabs using JavaScript

D365: Execute PowerAutomate from Ribbon button using JS

Recently, we had a requirement to execute PowerAutomate on click of a button on Lead record. In this post, we'll see how to do that. While creating the PowerAutomate, select the trigger as "When an HTTP request is received" as shown below: We can pass parameter to the PowerAutomate in JSON format. In this example, … Continue reading D365: Execute PowerAutomate from Ribbon button using JS