CRM 2015/2013 ER Diagram Generator Tool

Many of us have the need to document ER Diagrams (Entity Relationship Diagrams) as a part of our MS Dynamics CRM implementation.
Creating these ER Diagrams is one part, and formatting, color coding etc. these diagrams is another which thereby increases the documentation time as well. Sometimes this activity can be erroneous as well as we need to open each and every entity customization, browse through all the 1:N, N:1 and N:N relationships and then put them in the diagram as well.

So, here is the tool which would take care of all the above activities. The tool is simple to use and gives Sure Step color coded ER diagrams using MS Visio as the one shown below.

ER_7

This tool is simple to use and gives Sure Step color coded ER diagrams using MS Visio. Here is the tool can be downloaded from CodePlex and below are the steps for using this tool.

Download the tool from here

Step 1: Once you unzip the solution. The tool can be run by clicking the “XRMERDiagGenerator.exe” file.

ER_1

Step 2: After the tool comes up, you would have to connect it to a CRM organization by clicking “Sign in to CRM”. At this point you would get a pop-up to connect to a MS Dynamics CRM On-premise/ Online environment. This control would be familiar to most of us working with MS Dynamics CRM. Once a connection is made, you would be able to select and connect to your desired Organization.

ER_2

Step 3: You would get a screen as below showing your connection information and suggesting to click the “Get All Entities” button. Now at this time, the tool would be fetching all the entities present in your selected organization so that its easy for you to select your required entity/entities and generate ER Diagrams for them.

Since a Metadata call is a costly operation in CRM, this operation would take sometime approx. 5-10 minutes.

ER_3

Step 4: Once the List of entities are load, you can sort them by clicking the “Entity Schema Name” header. You can select all the entities or undo your selection by clicking the “ Select All” and “Select None” buttons. You can also select one or multiple entities by using the “Ctrl” key while selecting the entity rows.

ER_4

Step 5: Now click “Generate Visio”, to generate the ER Diagram for the selected entity/ entities in MS Visio.

ER_5

The “.vsd” file would be generated in the tool’s directory itself. Here is one sample ER diagram as created in MS Visio by this tool.

  ER_6

Pre-requisites for the tool:

1. You should have MS Visio installed in the system where the tool is running. Link for downloading a trial version for downloading MS Visio 2013 is here.

2. You should have .Net Framework 4.5 installed on your system. Although I haven’t checked out my tool on a system that doesn’t have .Net Framework 4.5 installed, but I think it should be there for my tool to run successfully. Link for downloading .Net Framework 4.5

3. You should also have Windows Identity Foundation installed and enabled in your system. Link for downloading Windows Identity Foundation.

Color coding for the Entities is as follows:

1. If the attribute is a primary key for the entity, then “[PK]” would be appended to the attribute.

2. A Business owned entity would be colored “Orange

3. An Organization owned entity would be colored “Green”.

4. A User/Team owned entity would be colored “Blue

5. If the entity does not fall into any of the above categories then would be colored “White”.

CRM 2013/ 2015 : Performance Analyzer Tool

I hope many of you would be knowing this, but just thought to share this as a refresher at the end of the year. With the release of Dynamics CRM 2013 SP1, Microsoft has introduced an analyzer to track performance on CRM form and view Loads.

This tool is an efficient one as we do not need to rely on the traditional Fiddler Tool to analyze the performance bottle necks of the CRM page. Its simple to use and provides detailed statistics.

We need to follow simple steps as below to take advantage of this feature.

Step 1: Open a CRM Form. For example you can open an account form.

Step 2: Then using your keyboard select Ctrl + Shift + Q to view the performance analyzer. The analyzer window as shown below would come on top of your browser.

Perf_1

Step 3: After this we need to “Activate” this utility. In order to activate this utility click on the “Enable” button as highlighted above in the screen shot.

Step 4: Then using F5 refresh your CRM form, the utility will close. Do not bother about this as it is a normal behavior.

Step 5: Once the form has refreshed select Ctrl + Shift + Q again, this time the utility will display the performance of the form load.

Perf_2

Some notable points:

– This utility is not only restricted to Forms, it will work on Views as well.
– This utility works with both CRM Online and On-Premise versions of CRM 2013 SP1 (and above) and CRM 2015
– The tool seems to be working with both IE and Chrome
– Probably a good idea to Disable the Utility when not in use, only Enable when needed.

Happy new year to all!

CRM 2015: How to create Custom Help for your users

With the new Microsoft Dynamics CRM 2015 version you can customize the “Help” guide for the CRM users.

You can replace the default “Help” of the system at a global level (useful if you have a highly customized system and you want to completely replace Help) or at an entity (record type) level. The implementation is very simple in either case.

To replace the default Help system with a global URL, we have to navigate to Settings >> Administration >> System Settings. Here provide your custom URL for “Global custom Help URL” and save the System settings.

Help_1

So, now once you click on the below highlighted option, it would re-direct the users to the page mentioned under “Global custom Help URL”, rather than the usual CRM Help page.

Help_2

You can also Enable custom Help for each Entity by selecting the Use custom Help for customizable entities option in System Settings.

To replace the default Help system at the entity level, you first need to enable custom Help through the System Settings dialog box, and then go to Settings > Customizations > Customize the System and select the entity you want to create custom Help for. Then just select the Use custom Help check box and enter a Help URL. After this Save & Publish your customizations as usual. Now, when a user clicks the Help button for that entity, they’ll get the custom Help page that was specified for the respective entity.

Help_3

Help_4

If you want to make your Help system more dynamic, you can append parameters to your URL. For example, you could redirect all Help to a global custom Help URL and display different pages based on the Entity Name parameter. You can also access parameters for Language Code, Entry Point, or Form ID.

Dynamics CRM 2015: Hierarchy Visualizations And Its Limitations

With Dynamics CRM 2015, Microsoft has added a new way to look at records, and their relationships to records of the same entity type.  This new functionality is called Hierarchy Visualizations.  In this post I would like to show you what the hierarchy visualizations look like, but first, let me show you how to set them up.

First off all, you’ll need to go to the Customizations area of CRM, and open up the entity you want to enable hierarchy visualizations for. 

**Note, after installing 2015, some entities are already enabled and setup for hierarchy visualizations, and you won’t be able to change the out of the box setting (accounts, positions, products, and users).  Other entities are setup to allow hierarchy visualizations but not setup by default.  This includes all custom entities.

A new “Hierarchical” field has been added to the 1:N relationship definition. 

**Note that setting this to “Yes” will automatically set the hierarchy flag to “No” for on any other relationship on this entity that was previously setup as hierarchical.  CRM 2015 only allows you to setup 1 hierarchy visualization per entity, and the Parent Entity and Related Entity have to be the same. Limitations to these Hierarchy relationships are also enumerated at the end of this blog.

After configuring your 1:N relationship, you need to navigate to Hierarchy Settings within the entity definition. (For demonstration purpose here, I have selected the OOB Parent Account Relationship on account. As this would be created OOB on upgrading to CRM 2015, hence the Hierarchical Field is set to “Yes” and is disabled.)

Heir_1

Once there, you can create your new Hierarchy Setting.  The Hierarchy Setting is used to define what 1:N relationship to use, and which Quick View Form to use for the tiles that appear in the hierarchy visualization.  You can use one of the out of the box Quick View Forms, or create a new one specifically for the hierarchy visualization. 

There are a few important notes to make about Hierarchy Settings:

  • Only the first 4 fields from the Quick View Form will currently display on the tile. 
  • You can only have have one Hierarchy Setting per entity even though the solution explorer makes it look like you can have multiple.
  • Hierarchy Settings are Solution Aware and will be exported / imported across organizations

Heir_2

Once you have your relationship and your Hierarchy Setting setup correctly, when you navigate to a grid for this entity, if there is a value populated in the field for the relationship you setup for specific records, you’ll see an icon in the grid indicating that record is part of a hierarchy.

For example, in my case I have set up the Hierarchy on the Parent Account relationship. So, whichever accounts have a parent account defined for them, they would appear with the hierarchy symbol on the grid.

Heir_3

Clicking on that icon will open up the Hierarchy Visualization for the record you selected, and show any siblings of that record, the parent of that record, and any children related to that record.

Heir_4

Once you have the Hierarchy Visualization open, there are a few things you’ll notice.  First, there’s a list on the left as well as the larger tiles on the right that are showing the 3 levels of the hierarchy based on what record you selected (current layer, parent, and children)

You can also click on the check mark at the bottom right corner of the tile that will select that record so you can take actions on similarly as if you selected it in a grid (such as assign, edit, share, etc.).

Clicking on the main area of the tile (and not the check mark in the bottom right corner), or selecting a record in the list on the left, will color that tile blue and make it the focal point of the hierarchy and redraw the hierarchy tree.

Finally, on each tile (and also on the list on the left), there’s a “pop-out” icon that when clicked, will open up the form for that particular record in a separate tab/window.  If you’re on the form for a record that’s part of a hierarchy, you’ll be able to quickly display the hierarchy view by clicking an icon in the top right corner of the form.

Heir_5

With these changes above, Microsoft also added a couple new operators to Advanced Find.  Note, these can only be used in Advanced Find queries (don’t show up on sub-grids of specific records)

  • Under:  Finds all records that are UNDER a specific node (For example: all Accounts under “Parent Contoso” Account)
  • Not Under:  Inverse of Under

Heir_6

I would be researching further on the “Advance Features” in my next blogs.

Also an important thing to note is that all of the functionality discussed above will work on the Mobile Client Application as well.  So this powerful new feature will NOT be only available on the web client, making it even more powerful!

With Hierarchy Visualizations, there are still some limitations to be aware of:

  • Maximum of 4 fields are displayed on a tile
  • Visualization is based on a single entity (not multiple hierarchy) – A relationship between 1 entity and itself
  • At most 1 hierarchical relationship allowed for an entity
  • Only 1:N relationships can be enabled to be hierarchical

As the product matures and Hierarchy Visualizations get more real world exposure, I’m sure Microsoft will invest time into resolving the limitations above (e.g., allowing hierarchy  visualizations between different entities, displaying the visualization somewhere other than the entity form like a chart or dashboard, etc.). 

CRM 2013 – Add Pre-Search Filters for Lookup

Often we are faced with a situation wherein we need to filter search results for lookup based on some other value/ conditions which is dynamic in nature.

For example, if we have a lookup on opportunity as “Primary Sales Rep” which should be filtered and should show only those members who are a part of the Sales Team. Then in this case we can add filters to the “Primary Sales Rep” lookup to show only those members who are present as a part of Sales Team.  With CRM 2013, these filters can be added dynamically in the javascript webresource in the OnLoad() event.

Below is the source code which demonstrates adding “PreSearch” filters to lookups in CRM 2013.

function onLoad(){
preFilterLookup();
}

function preFilterLookup() {   
    Xrm.Page.getControl(“new_lookuptobefiltered“).addPreSearch(function () {
        addLookupFilter();
   });
}
function addLookupFilter() {
    var searchValObj = Xrm.Page.getAttribute(“new_lookupvalue“).getValue();

    if (resident != null) {
            fetchXml = “<filter type=’and’><condition attribute=’new_lookupvalue‘ operator=’eq’ value='” + searchValObj[0].id + “‘ /></filter>”;                    Xrm.Page.getControl(“new_lookuptobefiltered“).addCustomFilter(fetchXml);
    }
}

In the above code I am filtering a lookup “new_lookuptobefiltered” based on some other lookup values that the user would selected dynamically from the form. We can add as many filter conditions here as we need.

This also helps us to resolve dependent lookups issues and also in cases where in 2011 we had to bind the lookup views dynamically. Happy exploring CRM 2013!

CRM 2013 – get logged in user name in javascript

 

I know many of us might have already explored this, but I wanted to share this info on the new Java script functions available with CRM 2013. With CRM 2013, its easy to get the “Full Name” also of the logged in user in Java script with the function:

1

Xrm.Page.context.getUserName();

So, earlier with CRM 2011 we were able to get only the logged-in User Id and would have to do an ODATA or SOAP XML fetch call to retrieve the “Full Name” information.

But, with CRM 2013 we can get both with the following two functions:

var loggedInUserInfo = {UserId: Xrm.Page.context.getUserId(),

UserName: Xrm.Page.getUserName()};

alert(“Logged In User Id: “+ loggedInUserInfo.UserId);

alert(“Logged In User Name: “ + loggedInUserInfo.UserName);

Hope this helps!

Generate Javascript soap xml calls from C# .Net code

In CRM customizations while writing java scripts we sometimes need to accomplish requirements involving SOAP XML calls like fetching data, setting state of an entity or calling a workflow etc.

With this blog, I would like to showcase the way of writing effective SOAP XML calls easily for all possible requests that are available with the “Execute()” method of organization service.

All of us would have downloaded the CRM 2011/2013 SDK. Now, the SDK comes with some tools and one of them is the SOAP LOGGER tool. The tool can be found at:

Installed SDK Path\sdk\samplecode\cs\client\soaplogger

First, we need to create our own project in Visual Studio and include the reference to the project “soaplogger.sln” from the above location to our newly created project:

1

Now, the way we write code for creating an organization service proxy and “Execute” a request, we need to write code using the soap logger. For example, the below code is for executing a workflow.

public class Helper
    {
        /// <summary>
        /// Execute Function to execute the request and
        /// create the respective Javascript equivalent
        /// </summary>
        public void ExecuteFunction()
        {
            using (StreamWriter output = new StreamWriter(“output.txt”))
            {
                OrganizationServiceProxy serviceProxy = CreateOrganizationServiceProxy();

                var uri = new Uri(“https://xrmadvice.api.crm.dynamics.com/XRMServices/2011/Organization.svc”);
                SoapLoggerOrganizationService slos = new SoapLoggerOrganizationService(uri, serviceProxy, output);

                /*Code over here is to execute the workflow. It can be changed
                 for Entity Create/Update/SetState etc.*/
                try
                {
                    ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()
                    {
                        WorkflowId = new Guid(“4017B077-B13D-45A0-B222-2D9B7CF086CF”),
                        EntityId = new Guid(“01987DAC-1A06-E411-93F2-005056AB5C1B”)
                    };

                    ExecuteWorkflowResponse response =
                        (ExecuteWorkflowResponse)slos.Execute(request);
                }
                catch (Exception ex)
                {
                }
            }
        }

        /// <summary>
        /// Create Organization Proxy Service
        /// </summary>
        /// <returns></returns>
        private OrganizationServiceProxy CreateOrganizationServiceProxy()
        {
            var clientCredentials = new ClientCredentials();
            clientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
            clientCredentials.UserName.UserName = “bohnnie@xrmadvice.onmicrosoft.com”;
            clientCredentials.UserName.Password = “**********”;
            var uri = new Uri(“https://xrmadvice.api.crm.dynamics.com/XRMServices/2011/Organization.svc”);
            Uri homeRealmUri = null;
            var serviceProxy = new OrganizationServiceProxy(uri, homeRealmUri, clientCredentials, null);
            return serviceProxy;
        }

}

2

In the above code we need to specify the name of the text file where the javascript output of the equivalent code would be the output. In my example i have given the file name as “output.txt”.

After this, execute the code and ensure that it executes successfully!

Now navigate to the respective “Debug” folder and the file “output.txt” would contain the respect java script equivalent for the C# .Net code.

3

All that we need to do now is copy paste the java script code from the “OutPut in JavaScript” section and our SOAP Call is done.

4

The above code need not be changed while switching across environments because it is generic however there are few considerations that I have listed below.

**Few considerations here while using the java script code:

5

1. The code currently uses “ActiveXObject” for creating the HTTP Request. This works only in IE, so better is to use XMLHttpRequest() so that it is compatible with all the browsers.

var xmlHttpRequest = new XMLHttpRequest();

2. Also while calling the xmlHttpRequest.Open() call, make sure to pass the complete Organization Service URL as sometimes the relative path might hinder with the authentication. So, we change this as:

xmlHttpRequest.open(“POST”, Xrm.Page.context.getClientUrl() + “/XRMServices/2011/Organization.svc/web”, false);

So, by appending “Xrm.Page.context.getClientUrl() “ resolves this issue.

As shown above with the SOAP Logger tool you can create any SOAP XML call by comfortaby writing C# .Net code and not worrying about java script!