Sunday, June 7, 2015

Keys and Dynamics CRM 2015 Online - Update 1

Recently, Microsoft released Update 1 to its online subscribers.  This included a number of features and enhancements, and one I wanted to talk about today is Keys. I read through the release notes and somehow completely missed this feature as did many people in the CRM world that I work with, so I figured that making a post on the topic wasn't a bad thing.

So, keys.  When I first heard the term I thought back to my database days and thought that it would be related to records being unique...but CRM already had the duplicate detection engine so in my mind it had to be something else.  After some digging and playing with the new feature though, CRM Keys exactly what I thought:  Unique values on an entity.  It can be based off one attribute or multiple (compound keys for the SQL readers out there).  So if you start using Keys, you don't have to re-implement that plugin enforcing unique-SSNs requirement for the 10th time.  So how do we do this?

First, open up a solution or click on Customize the System.  Pick an entity in your solution, and you'll see a new Keys option:


Inside that setting, you create a new key, give it a unique name like you were creating a new attribute, then select which attributes on the entity should be involved in the Key [I removed my entity prefix from the screenshots]:


And that's all there is to it!  Test it out, and you'll get a message similar to the following when you try to create a duplicate record according to the new Key you just created...and you'll notice that it's blazing fast:



But the question remains, how does this work?  What's it actually doing?  Well, if you try to create a key that would be invalid (say, unique on first name), you get a message similar to the following:


As you can see, the name of the actual database key that the system is trying to create is displayed...ndx_for_entitykey_<keyname>.  So at the end of the day, these new CRM Keys really are just database keys/indexes.

One thing I'd like to get around to playing with is are these actual keys?  Can these be utilized not only for making sure records are unique, but also to create database keys on tables to speed up processing?  Hopefully I'll get to that in the future, and when I do I'll post my findings here.

Happy keying!

1 comment: