{Dynamics CRM Scripting} Exploring the Xrm.Internal namespace in CRM 2013

Recently i cam across this library in CRM 2013. And I found a lot of helpful methods which could facilitate you during your development. Please check for the screenshot below which shows some of  the methods.

screen 40

Notable are:

1. Xrm.Internal.getEntityName(<entitytypecode>) – you pass in the entitytypecode and get the logical name for the entity

2. Xrm.Internal.getEntityCode(“<logicalname>”) – you pass in the entity logical name and get the objecttypecode. This is very useful where you can need the entitytypecode in the form

Check for the screenshot below to see the usage of the above two methods

screen 41

Besides these other utility methods are:

3. Xrm.Internal.openDialog – this you can use to show a modal dialog in a similar manner in which CRM 2013 shows the modal dialogs.

4. Xrm.Internal.openErrorDialog – this you can use to show an error dialog like CRM 2013.

Check out the following link to see how to use the above methods to suit your needs.


Please note that is a not a documented library for end users and hence any changes to library by microsoft in the future would render you code unusable.

Hope this helps!


Dynamics Crm 2013 Access Teams – Demysitified

By now many of you might have already explored the concept of Access Teams that has been introduced with CRM 2013. If not then I would suggest to go through it. Personally i kind of liked it as it helped me to escape sufficient amount of coding in my current project.

In this post, I will not explain how CRM 2013 Access Teams work functionally. But I would rather explore as to what does CRM do underneath to make it work.

I have logged in to CRM with a user who has sales person security role in CRM. I have a custom entity called ‘Test Entity 1’ in my CRM. The sales person security has the following privileges on the Test Entity 1. Check for the screenshot below.

screen 30

Now I have also created an access team template for Test Entity 1. I have configured the Access Teams on the form of Test Entity 1 and opened a record of the entity called ‘Test Entity Record 1‘. Check for the screenshots below.

screen 31

screen 32

Now I go ahead and add the user ‘Test Crm User 1′ in the access teams grid of the opened record. The user now have the privileges to this record as per provided in the access team templates.

screen 33

Let’s check now how is this made possible in CRM.

I open SQL server database and query the Teams table order by createdon descending and following is the result i get.

screen 34

Carefully look at the Team Name – 33835ea1-978d-e311-b84b-463500000031+5c2bde09-60c8-e311-9bb1-463500000031

Let’s check what the first guid refers to. When I query the PrincipalObjectAccess table with the ObjectId = 33835ea1-978d-e311-b84b-463500000031′, the following is result I get.

screen 35

Here objecttypecode = 10005 in my system is the Test Entity 1 entity. So CRM underneath created a new Team and shared the record with the newly created team. The principalid field value is nothing but the ID of the team.

So now let’s explore the second guid of the team name  – ‘5c2bde09-60c8-e311-9bb1-463500000031′.

This is nothing else but the id of the access team template. Please check for the screenshot below.screen 36

Now what happened to the user that has been added to the access team. Let’s pull out the team from the advanced find view.

screen 37

screen 38


screen 39

So we can see that user is added as a member of the team. So if one more user is added to the access team, internally crm would add the user as a member of this team

Hope this helps you in understanding the underlying structure of CRM 2013 Access teams.


“Must specify valid information for parsing in the string. at System.Enum.TryParseEnum” – Error while configuring Outlook with MSCRM

Recently while configuring outlook for our client, we got the above mentioned error. Also strangely it was working prior to one of our deployments that we did in the organization. So we became pretty sure that it has something to do specific with our latest customizations that we deployed to the environment.

What we did is we compared all the changes that we made in the recent deployment, specifically the Enum fields, since the error says that it cannot parse the Enum value.

What we found is that, the “searchable” property of the field “importsequencenumber” of one of the custom entities has been changed to “No”. We set it to “Yes” and published the customizations.

After that we re-opened outlook and tried to configure the Outlook client and all worked well much to our joy.

Hope this helps and saves you some time when you face similar issue.


{Dynamics CRM Business Process Flow}Register Business Process Flow StageID and ProcessID in Plugins in CRM 2013

Microsoft Dynamics CRM 2013 introduced the concepts of Business Process Flows. For any entity which have business process flows enabled, CRM creates two fields in the entity

1. stageid

2. processid

On Change of process or stage for an entity, CRM allows you to register workflows. However through plugin registration tool, it is not possible to register plugins on change of stage or process. Also in images for steps you cannot add the processid and stageid parameters during update/ post create of the entity. You have to write separate queries altogether to fetch the processid and stageid for an entity during create/ update of entity in the plugins.

However there is workaround which helps you to achieve all of this in a very simple manner. Let’s see how this can be achieved.

CRM 2013/ 2011 SDK ships with the developer toolkit. Once you install the developer toolkit and open visual studio, you get an option to create CRM Solution. Check for the screenshot below.

screen 24

Just select that and CRM creates a solution for you with the Plugins Class library and also a special type of project called ‘CrmPackage’

Using the CRM Explorer, I have created a plugin on post update of Opportunity.

screen 25

Once the plugin is created, open the RegisterFile.crmregister file in the CRMPackage project. As you can see i have manually added stageid in the filtering attribute and stageid and processid in the post image.

screen 27

All you now need to do is right click the CRMPackage project and select “Deploy” from the menu.

once deploy is succeeded, open Plugin registration tool and you should be able to see the changes.

screen 28

Now as you change the stage of the opportunity, you can see that the plugin is fired and we are able to get the processid and the stageid in the post image.

screen 29

Hope this helps!


{Dynamics CRM Plugins} Images and Filtering attributes not supported for Plugins for custom Actions in CRM 2013

In CRM 2013, Microsoft has introduced the concept of actions which is a wonderful way to represent you custom business functionality in the form of a request that CRM platform would understand. Also on top of that, you can register plugins for the actions you create. However there are certain limitations when using plugins with actions.

To illustrate this, lets start with a simple example.

Say we create an action for contact entity named new_TestAction” as shown in the screenshot below.

screen 21

Now we open the plugin registration tool and try to register a plugin on post execution of the action. As you can see from the below screenshot, filtering attributes are not supported in that case.

screen 22

Also let us try to register a post image on the plugin. As you can see from the below screenshot, CRM would not allow you to register that image and gives u an error.

screen 23


So if you have a requirement to register a plugin on post execution of an action, please keep these limitations in minds and design accordingly.

Hope this helps!

{Dynamics CRM Business Process} Change the Active Stage Flag in CRM 2013 Business Process Flows

Recently in our project, we had a customer requirement where the customer asked to change the colour of  image of active stage of a business process flow for Opportunity.

Let’s see how this can be achieved.

OOB in CRM 2013, the active stage flag for a business process in bluish is colour. Please check for the screenshot below.

screen 19

However, the customer wanted the flag to be in green to comply with their existing colour scheme. A little bit of exploring and we found that CRM picks up the image from the following location

<Installation Folder>\Microsoft Dynamics CRM\CRMWeb\_imgs\ProcessControl\process_control_global_active_flag.png

We took the .png image and modified the image using Photoshop to change the background colour to green keeping the dimensions exactly the same and then  replaced the old image with the new one. Recycle the app pool, clear your browser cache and refresh the page and the changes are reflected in the CRM. Check for the screenshot below.

screen 20


I would suggest you take a back-up of the original image before replacing the same. Also you have to do this as a part of your deployment once you move from dev–>test–>prod.


Hope this helps!

{Dynamics CRM Business Rules} Custom Xrm Script and Business Rules on the same Field in Dynamics CRM 2013

With the advent of Microsoft CRM 2013 in came business rules, a wonderful feature of the new CRM version. However with new implementations, there would be always some new confusions creeping up. Well in many training sessions on CRM 2013, i keep getting the question – “Will my onchange handlers and business rules work at the same time on the same field?”.

The best way to get the answer is to try out only. So let’s do a small test which i myself faced in one of my implementations. I was faced with a scenario where I had to to do whole lot of stuffs on change of field including clearing out certain other field values. All of them but clearing stuff was possible with business rules. So had to write a custom onchange event handler for the field. And yes both the business rules and my custom code triggered. Let’s see this with a simple example.

In the contact entity, for the email field I have a simple business rule which make the email field mandatory as soon as First Name field is entered/ changed by the user. Also for experimental purpose, I will register on on-change of First Name, to show a alert. Check for the screenshots below.

Screen 14

Screen 16



Now when I changed the First Name for a new Contact, first of all my custom jScript code fired. When I closed the alert by clicking OK, the Email field was set to Business Required by the Business Rule.

Screen 17

Screen 18

However remember the following MSDN Documentation – “When you set a field value by using a business rule, any OnChange event handlers for that
field will not run. This is to reduce the potential for a circular reference, which could lead to an infinite loop. ”

So when you are designing business rules and customer onchange handlers for your implementations, please do take all this into consideration.

Hope this helps!

{Dynamics CRM Social Pane} Hide Posts From Social Pane in CRM 2013

In CRM 2013 Microsoft introduced the Social Pane, also known as Record Wall. Recently in our project we had a requirement to disable posts for a particular security role. To do that the first thing we did is to remove the Post Privileges for the security role. Please refer to the screenshot below.

screen 12

As you can see, remove all the privileges for the POST entity from the security role.

However after this change is made, when the user logs into the application, this is how it looks to the user.

screen 13

However what we needed to do is to hide the Posts tab altogether for this security role. A little bit of searching and found the below link. This gave us exactly what we needed.


All you need to do is call the method HidePosts() as mentioned in the link in the onload of the form and check for the currently logged in users security roles. And then hide the  post tab if the security role matches the condition.

Hope this helps!

{Dynamics CRM Business Process Flow} Prevent user from moving to previous stage in CRM 2013 Business Process Flows.

In CRM 2013 Business Process flow, the user can move both forward and backward to next stage and previous stage respectively using the Next/ Previous arrows. However sometimes your requirement might be to have process flows unidirectional. In that case you would not want to show the previous arrow shown to the user. Let’s see how you can achieve this using  jQuery.

Following is a business process flow that we have set up for the opportunity entity.

Screen 10

As you can see, we have both the Previous and the Next Stage buttons here.

Let’s how we can hide the previous stage button

In google chrome, using developer tools, we can explore the HTML for the Previous Stage arrow. Following is the HTML that we have.

screen 11

The Id of the Previous stage arrow is stageBackActionContainer. All we need to do is hide this div and increase the width of the “Next stage” div so that it occupies the vacant space using the code below.

function hidePreviousStageButton(stageBackActionContainer, stageAdvanceActionContainer) {
$(“#stageAdvanceActionContainer”).css(“width”, “90px”);

All you need to do is call the hidePreviousStageButton in the onload of the form.

Hope this helps!

{Dynamics CRM} Control CRM 2013 Business Process Next Stage and Previous Stage flow using JScript.

Recently in our project we needed to restrict the business process flow from one stage to another depending on certain conditions. The problem was that OOB CRM 2013 does allow you to plugin your custom client side code when the “Next Stage” or the “Previous Stage” icons are clicked. You can obviously register Plugins and Workflows on the business process stage change but you cannot stop the change of stages using the same. Let’s see how we can achieve this.

Below is the screenshot of an example business process flow for opportunity entity. Let’s explore what CRM does here. I have opened Chrome Developer tools and trying to explore the HTML for business process flow. I have selected the ‘Next Stage’ button.

screen 9

The id of the div is “stageAdvanceActionContainer”.

So what we need to do is override the click event with our custom function and then if our condition meets we would call the OOB event handler. The code below does the same.

function  registerBusinessProcessEvents()


var originalNextStageHandler = $(“#stageAdvanceActionContainer”).data(“events”)[“click”][0].handler;


// unbind the original next event handler



$(“#stageAdvanceActionContainer”).click(function (e) {

// perform your custom logic here. If you want to move to the next stage just call the code below.


$.proxy(originalNextStageHandler, $(“#stageAdvanceActionContainer”))(e);





All you need to do is call the registerBusinessProcessEvents  function during the onload of the form.

Similarly the ID for the previous click handler is “stageBackActionContainer”. And you can handle it in the same manner as above.


Please note that is an unsupported customization and might not work if Microsoft decides to change the id of the div elements or the rendering model in future rollups.


Hope this helps!