Posted in Uncategorized

Search For Privilege Name Using Privilege Id

Quick post on how to search for privilege/permission name using privilege Id. You often in dynamics receive an error like below during your plugins or Web Api requests.:

“user is missing privilege ba09ec92-12c4-4312-ba16-5715c2cbd6da”

looking at the error, its difficult to tell what is the permission missing and on what entity.

Use this approach

All privileges are stored in an entity called privilege : Read more here.
you cannot see this entity in dynamics CRM front-end as its not available however you can easily query this entity using Web Api.

  1. Get web api url of your organization by going to Settings > Customizations > Developer Resources > Web API instance url:


  2. Append this url with “privileges?$select=name” and put it in your browser:$select=name


  3. hit Ctrl+F and search using id:


  4. Now we know the id refers to “PrvReadContact”. Go to the security role and assign appropriate read access on contact entity.

    hope this helps!

Posted in CRM Code Helpers, Uncategorized

Plugin on Retrieve Multiple in CRM.

Filtering records using javascript in subgrid or a view is unsupported and doesnt work hence here is how you can/should filter subgrid records using a plugin.

Nishant Rana's Weblog

Recently we had a requirement to filter sub grid on one of the forms. We thought of using Plugin on Retrieve Multiple for this.

Here we were showing Opportunity Sub Grid on Account form.

So we created a view for Opportunity that will be used as Sub Grid. Used it as Related Record Sub Grid so that we can have the GUID of the Account record being passed to the plugin.

The problem we faced à Sorting and Paging stopped working for the Sub Grid.

Hope it helps..

View original post

Posted in Microsoft Dynamics CRM Services

Prevent Data loss/Duplicates Using Concurrency Behavior In Dynamics CRM

This blog is just a reference to very important article on dealing with a problem when two or more update or delete operations on the same piece of data happen at the same time. This situation could potentially result in data loss.

Explanation : Reduce potential data loss using optimistic concurrencyReduce potential data loss using optimistic concurrency.

Sample Code : Use optimistic concurrency with update and delete operations

Posted in CRM WebApi/Javascript, Dynamics CRM 365 Online

Get User’s Teams Using WebApi JavaScript In Dynamics 365

If you need to get current/logged in or of any other user’s all teams. You have to look for the N:N relationship schema name and use that association in WebApi request:


So below is the code you can use to achieve this requirement. I have just retrieving the name of the teams associated and putting an alert on Onload of a form.

I have generated the code using Rest Builder Tool . And added the filter ($filter=systemuserid eq  IdOfTheuser) manually.

function GetUserTeams()
    var userSettings = Xrm.Utility.getGlobalContext().userSettings; // userSettings is an object with user information.
    var current_User_Id = userSettings.userId; // The user's unique id
    var newid = current_User_Id.slice(1, -1);	
    var req = new XMLHttpRequest();"GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/teams?$select=name&$expand=teammembership_association($filter=systemuserid eq "+newid+")", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 200) {
            var results = JSON.parse(this.response);
            for (var i = 0; i < results.value.length; i++) {
                var name = results.value[i]["name"];
        } else {

I am calling the function on Onload event of lead record. My user has two teams associated to it:



Important – Make sure you format the code fully before you use it. i.e use the latest method in the script i.e not using Xrm.Page but rather the formContext for v9.

I hope this helps! Cheers!


Posted in CRM WebApi/Javascript, Dynamics CRM 365 Online

Get Selected Record Information From Main View Or A Subgrid In Dynamics 365

I recently had a requirement to get selected record id from a main view of an entity i.e. Home page view of an entity and also on a subgrid within the form.

I also needed to pass this ID to my action to do some further operations in the plugin. This is how I did

I have taken reference from  here  and here.

  1. Download the managed solution of Ribbon Workbench from here and import it to your Dynamics CRM 365 environment:
  2. Create an unmanaged  solution and add contact entity to it. ( I am taking contact entity as I need to perform action on that, you can select any entity)
  3. Create two JPG images web resource with sizes as 16×16 and 32×32 for your ribbon button. You can take the desired image and rescale it online.
  4. Create a javascript web resource and below code to it:
    function GetRecordInformation(item)
        var selectedItem = item[0];
       alert("You have Select Record with Id=" + selectedItem.Id + "\nName=" 
    	+ selectedItem.Name + "\nEntity Type Code=" + selectedItem.TypeCode.toString() + "\nEntity=" + selectedItem.TypeName);
  5. Publish all your customization and open ribbon workbench tool from your solution area and select the solution that you have created and click ok:1.png
  6. Now drag and drop a button to the home grid view:1.png
  7. I have named this button as “SELECT” from the button properties you will get once you add and select the button on bottom right side of the ribbon workbench also select the Image for you button by providing the web resources we created in step 3 :1
  8. Now that out button is ready, we need to add a command and enable rule to it. to do this from the solution component area click on commands and click on + button and then from the right side click on add “Action”  and then click on “Javascript action”:1.png
  9. Add your javascript resource by searching in the lookup, if you dont find the script( i faced the issue). Simply add $webresource:WebResourceName for me its $webresource:new_SelectRecord  
  10. In the next box – add the function name i.e for me its GetRecordInformation
  11. Then click on Add parameter and select SelectedControlSelectedItemReferences Parameter. It should look like below:


  12. The final step is to add an enable rule to this command. To do this – from the solution component area click on Enable Rules and click on + button. On your right side you will be presented with below, Make sure you keep the information as it is:1
  13. We are done , now click on Publish from the ribbon. wait for it to completed as it might take some time. Once done navigate to your dynamics CRM and the main entity home view, you should see the button:1.png
  14. Select a record and click on the button and Bammmm! if everything goes right you will get the record information.1

You can do the same thing on a form subgrid, all you have to do is place the button on a form grid instead of home view.

I needed to further processing with the data so I called an action and passed the record id described here :

I hope this has been helpful!

Posted in CRM WebApi/Javascript

Make All fields Mandatory/Optional On Form Using Javascript

This should be a very quick blog on JavaScript helper which will let you make all fields on the form mandatory or optional. This requirement is hypothetical; I have not received any till now.

I am going to be calling below function on OnLoad event of the form based on a field value but you can very well call is on OnSave of record, or OnChange event of field.

For Dynamics CRM below v9:

function SetRequiredLevel()    
  var attributes =;
    for (var i in attributes) {

For Dynamics CRM v9 or above use below and make sure pass the context as first parameter ( checkbox) on the form editor while calling the function.

function SetRequiredLevel(executionContext)    
  var context = executionContext.getFormContext();
  var attributes =;
    for (var i in attributes) {



1. If you need to check some value you can do that i.e.

If ( fieldAValue = 1)

//the above code goes here//


2. If you have to make fields optional rather then mandatory , do this:

I hope this helps!!

Posted in Dynamics CRM 365 Online

Quick Note: Dynamics 365 CE Limitations


I often find myself struggling to get collated information on limitations on number of different component you can create in dynamics CRM.

I researched and found below link very useful, could not re-blog hence sharing them here. full credits to the owner of this content.

Dynamics 365 CE Limitations On Technet

Limitations On Creating CRM Metdata

If you don’t find anything related to Business Process Flow & Alternate Key Limitations :

  • There can be no more than 10 activated business process flow processes per entity.
  • Each process can contain no more than 30 stages.
  • Multi-entity processes can contain no more than five entities.
  • There can be a maximum of 5 alternate key definitions for an entity

Reference : Business Process Flow Overview  & Define Alternate Keys

Please note – It is strictly applicable to Dynamics CRM 365 Online, May or May not be true for other versions.

Please feel free to comment down below if you know any other limitation on any component in dynamics CRM.


Posted in Certifications

MB2-877 Field Service Exam Retiring…….

As we all know or for those who are not aware, Microsoft plans to restructure its certifications path due to which below dynamics CRM certification are going to retire:

Retiring on April 30, 2019

  • MB2-715 Microsoft Dynamics 365 customer engagement Online Deployment (originally published Feb. 24, 2017)
  • MB2-717 Microsoft Dynamics 365 for Sales (originally published Feb. 21, 2017)
  • MB2-877 Microsoft Dynamics 365 for Field Service (originally published Dec. 8, 2017)

If you have been following my blog , I have been preparing and also creating blog for MB2-877 Field Service exam. However because of this news I have stopped publishing more blogs. I might continue with these blog once we get the updated syllabus from Microsoft. 

Below blogs have been created so far:

  1. Overview
  2. Part -1 
  3. Part -2
  4. Part -3
  5. Part -4
  6. Part -5
  7. Part -6
  8. Part -7
  9. Part -8
  10. Part -9
  11. Part -10
  12. Part -11
  13. Part -12

I will restructure or create content again for this exam once we have updated exam on field service for dynamics crm.

See you soon!

Posted in Uncategorized

Quick Fix : Mandatory Field Error Shows Schema Name Instead Of Display Name

Quick blog on how to fix the error you get when you save a record which has some required fields on the header of the form and CRM shows the schema name instead of display name like below:


it shows the error which includes specific field logical name instead of display name which might be confusing for user and doesn’t look very much user friendly. In my case its still very much understandable but sometimes people change name on the form and in that case it will be worse situation.


All you have to do is put the same field on the form which is there on the header and hide it on the form. Open the form editor > select the section > look for the field and add it. Go to field properties and hide it by unchecking the visible by default box:


Save and publish all your changes and now try to save the record:


I hope this help!