Contact

Technology

Jun 03, 2013

Top 5 Time-Saving Tips for Microsoft Dynamics CRM 2011 Development

Jason Heilig

Jason Heilig

Default image background

After 18 months working with CRM 2011 I’ve discovered several small but important quirks of the system that if I had known earlier could have saved a lot of time and stress. I figured it would be worthwhile to compile my top five insights and share them for anyone else working with CRM 2011.

1. Audit Entries from the SDK

If you save a record that is being audited, it will record an audit entry with all attributes loaded on that entity, even if they weren’t changed. If you are not already, you should get in the habit of creating another instance of the entity that is your “save” object and populate it only with the fields that have changes you want to persist to the database. This will also provide you an easy way to determine if there have been any changes on the record. Even if there are no populated fields on the object, it will create an audit record—but it will be blank because nothing was changed.

2. Retrieving Data Using Linq

Microsoft is aware of how excruciatingly slow Linq integrated web services is, and hopefully we will see improvement in the near future. If you are looking for ways to speed up SDK code, it could be your data access. Using Linq requires fewer lines of code; however, you cannot specify columns to retrieve, causing more data to be pulled than may be required. I have found the performance is greatly improved by using RetrieveMultiple calls directly through the OrganizationServiceProxy. For example, let’s retrieve all notes for a given Account.

If you have code using [Entity]Set.Where() to do data access in CRM, like the following:

List<Annotation> notes = svc.AnnotationSet.Where(x => x.ObjectId.Equals(id) && x.ObjectTypeCode.Equals(Account.EntityTypeCode)).ToList();

I would recommend trying this instead:

OrganizationServiceProxy xrm; //Set up during initialize

______________________________________________________________________

FilterExpression criteria = new FilterExpression();

criteria.AddCondition(“objectid”, ConditionOperator.Equal, id);

criteria.AddCondition(“objecttypecode”, ConditionOperator.Equal, Account.EntityTypeCode);

return cm.CrmRetrieveMultiplebyCriteria(Annotation.EntityLogicalName, criteria, new ColumnSet(“subject”, “notetext”)).Cast<Annotation>().ToList();

List<Annotation> notes = xrm.RetrieveMultiple(query).Entities.Cast<Annotation>();

You could add some tracing around your data calls to CRM and take note before and after. In many cases I’ve decreased the time of the call by 75% or more.

3. Currency Type on SDK Created Records

When creating a record of an entity that has a currency field, you must set the currency type on the record even if you only have one currency type. Otherwise the currency fields will not work. You will get an error when you load the record on any form with a currency field.

4. SDK Proxy Options

If you are running IFD (Internet Facing Deployment) using ADFS (Active Directory Federation Services), understanding the types of Organization Service Proxies can make a huge difference to your ADFS box. The two options are ManagedTokenOrganizationServiceProxy and OrganizationServiceProxy. While there may be some other differences, the primary difference our team noticed was that the ManagedToken version will reauthenticate with ADFS for every call to CRM. This causes a bottleneck in a lot of custom pages. Simply switching to OrganizationServiceProxy will greatly increase performance.

5. Default and Pinned Views Are Cached

The Outlook client locally caches default and custom pinned views. This may not sound like an issue, until you have a flat security model and a 50GB database, so the entire organization is trying to pull down several GB of data at once. The sheer bandwidth usage can easily bring the CRM system to its knees. The problem can be mitigated with smaller default views.  Users can still pin their own custom views, but unless the entire user base does it at once, the system can usually handle the load.

More Efficient CRM

Hopefully this information will help you avoid the time sink of tracking down the root cause of some of these issues, only to find they are natively in CRM.

Credera has extensive experience with CRM systems, including Microsoft Dynamics CRM. If you have questions about CRM or Microsoft development, please contact us for more information or follow us on Twitter @CrederaMSFT.

Personalize marketing campaigns and increase revenue with Microsoft Dynamics

Explore Our Microsoft Consulting Services  →

Conversation Icon

Contact Us

Ready to achieve your vision? We're here to help.

We'd love to start a conversation. Fill out the form and we'll connect you with the right person.

Searching for a new career?

View job openings