Tag Archives: MSDYNCRM

Dynamics CRM Developer Tip O’ the Day: Working with Tabs

I learned an important lesson yesterday, again, on working with tabs with Dynamics CRM forms.

There are several ways to reference tabs when writing JavaScript and using the Xrm.Page model.  You may reference the tab by number, like this:

Xrm.Page.ui.tabs.get(2)

Note: Tabs are numbered starting with zero for the first tab.

Or by name, like this:

Xrm.Page.ui.tabs.get("tab2Tab")

It is always a best practice to use the name of the tab instead of the number because if you ever move the tab around the form, then the number will no longer be valid and any JavaScript you have written which references a particular tab in such a manner will start to cause some very strange user experiences.

By using the name of the tab, you will always be referring to the same tab, no matter where it may be located on the form.

In my particular case, this was a Dynamics CRM 2013 installation that had been upgraded from 4.0.  My JavaScript conversion tool, Transformer!, automatically converts the tab references using the number because of the naming convention applied to the converted forms, which is a GUID.

I had merged the original Information form with the new Entity form and in doing so, I had inadvertently moved the tabs out of place.  The logic in JavaScript involved changing the title of a tab as well as showing and hiding one of two different tabs, based on the value of an Option Set field.

I worked around my issue by renaming my tabs from the GUID value to tabxTab, which was the original CRM 4.0 naming format then modified my JavaScript to use that name instead of the number.

By the way, the same practice also applies to form Sections, which are named and referenced in a similar manner.

Dynamics CRM 2015 Spring: Plugin Trace Log

Yay! Finally, the good folks on the Dynamics CRM team have added the ability to log errors that occur in plugins and custom workflow activities.

Plug-In Trace Log

This is a new entity that we can access from the Settings, Customization area:

image

 

Setup

You need to enable the logging of exceptions to the plug-in trace log entity. Navigate to Settings, Administration, System Settings, then select the Customization tab.

image

Change the Enable logging to plug-in trace log setting to Exception.

Usage

Any time you have an unhandled exception in your plug-in or custom workflow activity, a log will be written to the trace log:

image

The detail looks like this:

image

Final Thoughts

This is a huge advance for those of us who develop with Dynamics CRM. Prior to this feature, we found I very difficult to record exception information, especially in CRM Online because any record we recorded to a logging entity was erased and when the transaction was rolled back, which was the common occurrence when exceptions were encountered.

This new entity and feature will be a most welcome addition.

Dynamics CRM 2015 Spring: New Forms Engine

The Spring Release of Dynamics CRM 2015 includes a new forms engine. You may have seen reference to this feature by the code name “Turbo Forms.”

The propaganda (marketing) says that we will get as much as a two or three times improvement in the rendering of a Dynamics CRM 2015 form.  My limited testing has not proven this statement but I can say that it is indeed faster.  I have a feeling that speed improvements will depend 100% on the contents of your form.

Let’s walk through the testing process.

Test Using Legacy Forms

The first test will be using the legacy forms to see what the original speed would be.  Perform these steps:

Test Setup

1. Clear your browser cache.

2. Navigate to Settings, Administration, System Settings.

3. Scroll to the bottom of the dialog and change the setting Use legacy form rendering to Yes:

image

4. Click OK to save your change.

Perform a Test

To perform the actual test, follow these steps:

1. Open a record such as an Account.

2. Press Ctrl+Shift+Q. This will open up the built-in and super-secret Performance Center tool.

image

3. Click the Enable button.

4. Refresh the web page (F5).

5. Press Ctrl+Shift+Q to display the Performance Center. This time, it will look something like this:

image

6. Click the very last flag on the right side of the Performance Center Window.

The text window below the graph will display something like this:

image

As you can see, it took a little over six seconds for all steps, including the loading of the sub-grids to occur.

Test Using New Form Renderer

To test using the new form renderer, perform these steps:

Test Setup

1. Clear your browser cache.

2. Navigate to Settings, Administration, System Settings.

3. Scroll to the bottom of the dialog and change the setting Use legacy form rendering to No:

4. Click OK to save your change.

Perform a Test

Repeat the testing steps performed earlier.

In my test, I see the following results:

image

The Results

So 4.4 seconds is not a 2x or 3x speed improvement but it is better than the previous form model. In addition, the form appears  to load faster.

One final caveat is this is a pre-release environment which, to my understanding, does not use the same hardware as production CRM Online.  This will probably mean that the speed will increase when the Spring Update finally reaches production release.

Final Thought

I’ll have a more in-depth article on the Performance Center soon.

Convergence Wrap-Up

This year’s Convergence conference in Atlanta was a blast.  Lots of new announcements for both the Dynamics product line as well as that of Azure.

In case you missed it, you can access many of the sessions in the Convergence Video Library, which I urge you to review as your time permits.

Convergence 2015 EMEA

Will be held in Barcelona, Spain on 30 November – 3 December 2015

Convergence 2016

Will be in New Orleans, Louisiana, USA, on April 4-7, 2016

Convergence 2015 (Atlanta) anyone?

Hi Folks,

If you are going to be in Atlanta, Georgia next week for Convergence 2015, please let me know.

I’ll be working in the Microsoft booth at these times:

  • Monday: 12-2
  • Tuesday: 3-5
  • Wednesday: 2-4:30

And I’ll be participating in at least one of the two Ask the MVP sessions:

If you are attending Convergence, look me up.  I’d love to hear what you are doing with Dynamics CRM.

Thanks, Mitch

Upcoming Developer Workshop: Extending Dynamics CRM

Just a reminder that my development workshop, Extending Dynamics CRM class, will be held Monday, March 9th through Friday, March 13th.

Course Description:

If you are looking to get started with Dynamics CRM development, and are looking for an instructor-led, hands-on workshop, then let me introduce you to Extending Dynamics CRM.

In case you did not know, Microsoft decided to only offer the Extending Dynamics CRM course via eLearning, starting with Dynamics CRM 2013. eLearning, which is a self–study program, is great for many people, but I think students gain a tremendous amount of learning and understanding from having an instructor who works with Dynamics CRM development on a daily basis. This student-instructor interaction combined with the ability for the student to ask questions and obtain clarifications, makes this course all the more valuable.

Download a PDF version of this document here.

Who:

This class is taught by Mitch Milam, nine–time Microsoft Most Valuable Professional for Dynamics CRM and an independent consultant specializing in Dynamics CRM architecture, development, and training.

What:

We have taken the topics normally covered by the official Microsoft Extending Dynamics course, and expanded their depth quite substantially. Instead of a three–day course, this is a five–day course with most of the extra content being the addition of a large number of hands–on labs. The information covered is relevant to both Dynamics CRM 2013 and 2015.

When:

Monday, March 9th through Friday, March 13th.

Class starts at 8:00am CST and will last five or six hours per day, depending on the topic. Please budget the entire day so that you have time to complete the homework assignments.

Where:

This is an Internet-based workshop. Classroom time and discussions will be facilitated using GotoMeeting. Each student will be given their own virtual development environment for the duration of the course. This will allow for the completion of labs and homework without causing conflicts with the other students.

Cost:

$1,995 per student.

Discounts are also available for two or more students.

Note: Due to the hands–on nature of this workshop, there is a limit of 12 students per class.

Eventbrite - Extending Dynamics CRM (March)

 

For more information visit:

http://www.infinite-x.net/extending-dynamics-crm

Correcting Filtered Views and an Inaccurate “First ten” list

I ran into a situation at one of my customers while performing an upgrade from Dynamics CRM 2011 to 2015. On several of their entity forms, they have a filtered lookup in place where one value is filtered based on the value of another field. In this case it is an Account/Contact set of fields, which looks like this:

image

The idea is that the Primary Contact lookup will be filtered to show only contacts associated with the Potential Customer. This is accomplished with the following settings on the Primary Contact field:

image

How this works

Here is how this set of settings works:

1. You first check the Only show records where checkbox,

2. Then set the first field to use the Potential Customer (Accounts) (Quotes) value.

This setting is a little confusing, so here is my interpretation:

Potential Customer = the Potential Customer field.

(Accounts) = look for Accounts. This field can also contain Contacts.

(Quotes) = I am guessing this means the quotes entity.

3. The second setting instructs the lookup to look for Contacts where the Company Name field of the Contact is the same as the Potential Customer field.

The Problem

The problem is that it does not seem to be working the way I think it should. When you first click on the magnifying glass icon, you will get a list of 10 contacts, that seem to be unrelated to the Account specified in the Potential Customer field, as you can see below:

SNAGHTML27ff74f6

If you scroll to the bottom of the list, and click on Look up more records, you will see the standard lookup dialog which is properly filtered:

image

This confuses the user quite a bit and makes them do extra work. 

The Solution

At this point, I am under the impression that this is a bug. The list of 10 items needs to be the same as the items shown in the actual lookup dialog.  This means we have to resort to a little JavaScript.

Add this code to the JavaScript library associated with your entity:

function preFilterPrimaryContactLookup() { Xrm.Page.getControl("new_primarycontactid").addPreSearch(addPrimaryContacLookupFilter); } function addPrimaryContacLookupFilter() { if (Xrm.Page.getAttribute("customerid") == null) { return; } var customer = Xrm.Page.getAttribute("customerid").getValue(); if (customer == null) { return; } fetchXml = '<filter type="and">' + '<condition attribute="parentcustomerid" operator="eq" value="' +

customer[0].id + '" />' + '</filter>'; Xrm.Page.getControl("new_primarycontactid").addCustomFilter(fetchXml); }

The first method, preFilterPrimaryContactLookup, simply adds what we call a Pre-Search condition to the Primary Contact field. That condition actually calls the second method, addPrimaryContacLookupFilter, to actually do the work.

addPrimaryContacLookupFilter extracts the ID of the Potential Customer, then creates a FetchXml Filter Condition where the Contact entity is filtered based on where the Parent Account (parentcustomerid) of the Contact is the same as Potential Customer of the Quote (in this case).

We finish this exercise by adding the following line to the form’s OnLoad event:

    preFilterPrimaryContactLookup();

Conclusion

As I mentioned, I think this is a bug. I’ve seen it happen and not happen with different versions of Dynamics CRM 2015.

If you are trying to implement this technique, start with the standard configuration of the field, using the field properties in the form editor and if that does not work as you expect, add the JavaScript.

System-Wide Alerts in Dynamics CRM 2015

Dynamics CRM 2015 implemented a new system-wide alerts to inform you of issues with things like the Server-side Sync process. They appear in the user interface as a yellow bar at the top of the page, as you can see below:

image

Clicking the View Alerts button will take you to the Alerts view where you may review the individual alerts.

At this point I am not certain what will be alerted on, besides issues with Server-Side Sync, but those for sure are there.

Viewing Alerts

The actual Alerts view is on the Dynamics CRM user interface at the end of the Sales Area:

image

The rather fascinating thing about Alerts, is that they are not actually Alerts, they are Traces.  So, when you are working with Advanced Find, you need to use the Traces entity.

image

Programmatic Access and Automation

The Traces (Alerts) entity is actually called TraceLog, which is the entity name to use when writing code using the Dynamics CRM SDK.

Traces are fairly locked-down so here are some of things you can do with the entity:

  • Create a workflow to trigger on the Traces entity
  • Perform a query using Advanced Find
  • In the SDK TraceLog is listed a “internal use only” but it appears you may use the SDK to perform standard CRUD operations.  NOTE: I have not tested this.

Security

Privileges for the Traces entity are found on the Core Records tab:

image

It would appear that everyone can Create, Read, and Append Trace records, but only the System Administrator role can delete them.  Since these are standard security roles, you should be able to change these settings if you wish.

Conclusion

Traces are a very interesting addition to the Dynamics CRM platform and I need to get more information from Microsoft as to its intended use and if we as developers can actually create alerts that may be seen by the System Administrator.

That will be my next step, when I have time.

Dynamics CRM Environment Diagnostics.

When you install Dynamics CRM (on-premise) or import an existing organization database, it performs a series of environmental checks to verify that you will not run into issues during the actual installation or import.

If you double-click on one of the warnings or errors it will open up a help file and show you details about the message.  That file can be found here:

C:\Program Files\Microsoft Dynamics CRM\Tools\EnvironmentDiagnostics.chm

I found it quite interesting to read through the various details to see what is checked. That might help you to know some of those things before you actually begin the installation or import process.