Skip to main content

Simple CRM Tools

A colleague of mine recently turned me onto some very useful tools that are simple and easy use. Often times as a CRM developer, we find ourselves needing either the entity type code or the GUID of the record we’re on.  We can easily obtain this information by creating a bookmark that displays either the GUID or the entity type code, directly from the form we’re on.  As an added benefit, we can also set the values to our clipboard so they can be pasted as needed.

To create these bookmarks, just browse to any CRM page and add it to your favorites.  Then, you can edit the bookmark and set the URL to the javascript you would like executed.

Here's the javascript to do so:

Entity Type Code:
javascript:if (crmForm.ObjectTypeCode){clipboardData.setData("Text", crmForm.ObjectTypeCode.toString()); alert(crmForm.ObjectTypeCode);}

Entity ID:
javascript:if (crmForm.ObjectId){clipboardData.setData("Text", crmForm.ObjectId.toString()); alert(crmForm.ObjectId);} else { alert('No id yet!'); }

Another useful bookmark is to find the Fetch XML used by an Advanced Find query.  To do this, create a bookmark using the below javascript, then create a query in advanced find and click Find.  Once your results are displayed, click the bookmark you just created to display the Fetch XML and copy it to your clipboard.

Fetch XML:
javascript:if (document.getElementById('fetchxml')){clipboardData.setData("Text", document.getElementById('fetchxml').value.toString()); alert(document.getElementById('fetchxml').value);}


  1. Great tips!
    These work best if you have configured IE to open popups in tabs rather than new windows, or use CTRL-N to re-open the form full screen so you can get at the toolbars (or configure keyboard shortcuts for the bookmarks)

  2. Thanks!...and that is a good point.


Post a Comment

Popular posts from this blog

Announcing the New Dynamics 365 Toolbot Chrome Extension!

Today I am excited to announce the new Dynamics 365 Toolbot! This new Chrome Extension will allow you to perform commands that will help you with your development or administrative tasks. The extension can be found here -

Note: Currently, due to the APIs being used, it only works on v9+.

First, navigate to the link above using Chrome and install the extension. Then, head to your Dynamics 365 environment and open a record. From there, click the little blue robot icon in the toolbar of Chrome which will pop open the Toolbot.

Click the text box and a list of commands will display. You can select or type any of the commands and hit Submit to execute them. Some commands require you to replace the default token with the desired request.

For example, select or type "display id" and click Submit and the Toolbot will display the current record's ID.

The majority of the commands should …

CRM 2011 LINQ - All Columns vs. Selected Columns

When creating LINQ queries in CRM 2011, it is easy enough to return the whole column set of the entity record without even thinking about the impact.  
Below is an example of querying all contacts from Chicago and returning all columns for each contact record.

This can be a big performance impact depending on the amount of columns that exist on the Contact entity and how many contact records exist in the system.  Another issue is that it could cause errors down the line if some of the attribute types are changed in the CRM system since the data is being bound to a model class that could be out-of-sync.
From the MSDN article on constructing LINQ queries (, we can see that the select clause creates a column set:
The select clause defines the form of the data returned. The clause creates a column set based on the query expression results. You can also define an instance of a new object to work with. The newly created object using the…

CRM 2011 Form XML

Retrieving and parsing the Form XML in CRM 2011 is pretty easy.  If you ever had to do this in CRM 4.0 you would know that the Form XML was stored in the OrganizationUI table.  In CRM 2011 it is now stored in the SystemForm table.  
So first things first, we need to build a query to retrieve the Form XML for an entity from the SystemForm table.

In my case, I just have the entity's name so I need to retrieve the entity metadata and find it's type code to use to filter the query.  I also filter the SystemForm Type by 2 which means it is the Main form (
Now that we have my entity's Form XML.  We can build a method to find all the attributes' schema names that exist on the form.  This method just parses the XML string into an XElement and then selects all the id's of the "control" nodes that exist in the Form XML.  This array of id's will be all the schema names of the attributes that exist on the for…