One of the challenges when integrating external data with Dynamics CRM is that in order to update a record via the API, you have to know the GUID of the record. Now with the introduction of alternate keys in the CRM 2015 Online Update 1 release, you can use a unique value in your data set as a key for updating records as part of an integration. This will work as long as the data type is an integer (whole number), a decimal number, or a string (single line of text). In today’s blog, we will show you how to utilize these alternate keys in your integrations. Let’s begin!

tips-and-tricks

Say you have a scenario where you have an external system that you want to integrate to your Account entity, and the system uses an email address as its key. You need to define the email address on the Account entity as an alternate key to make the integration easier to write and run faster. In order to do this, follow the steps below.

1. First, navigate to your solution and add the existing Account entity (if applicable). Then navigate to the Keys attribute of the Account entity and click New.

2. Next, select the field you want to use as a key, click Add, and give it a Display Name. Click Ok.

3. The system will then create a database index on that field to ensure fast querying and enforce the uniqueness of the values. Depending on how much data you have in your database, this could take a while. While this is processing, the key’s status will be either Pending or In Progress.

4. When the indexing operation is complete, the key’s status will change to Active. Congratulations! Your new key is ready for use!

You can use this key for Update and Upsert operations via the SDK. For further information on alternate keys, check out the MSDN article here: https://msdn.microsoft.com/en-us/library/dn932139.aspx.

That’s all for today, readers! If you’re interested in learning more about Dynamics CRM, consider attending this year’s PowerUp conference November 10-11, with a PowerUp Hands-On Day on November 12. This educational extravaganza is the CRM event of the year and is open to beginners and advanced users. PowerUp is a can’t-miss CRM event! We hope to see you there!

Happy CRM’ing!

Avatar for Joe D365

Joe D365

Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

There are 6 comments on this post

  1. Avatar for Joe D365
    Henrik Kappel - Wikap
    March 7, 2016

    Can this new alternate key be used when updating lookups (i.e. through scribe)

    Example with the email address alternate key above:
    – Could I use the email when populating the primary contact field on the account (instead of the contact guid)?

    BR,
    Henrik

  2. Avatar for Joe D365
    Henrik Kappel - Wikap
    March 7, 2016

    Can this new alternate key be used when updating lookups (i.e. through scribe)

    Example with the email address alternate key above:
    – Could I use the email when populating the primary contact field on the account (instead of the contact guid)?

    BR,
    Henrik

    • Avatar for Joe D365
      Joe CRM
      April 26, 2016

      Hi Henrik – Yes – when populating the primary contact you still need the GUID. However, with scribe, this is very easy as you can use a formula: DBLOOKUP(TextSourceField, “connection”, “table”, “lookup_field”, “substitution_field” ) where your TextSourceField has your email address, lookup is primaryEmailAddress, and substitution_field is the contactGUID. This does not require alternative keys. Take a look at DbLookupCached too in scribe. This caches the lookup value so with large migrations things run quicker.

      • Avatar for Joe D365
        Henrik Kappel - Wikap
        April 27, 2016

        Thanks for your reply – I see this as the traditional behaviour as it was before the alternate key introduction. I was hoping you could just fill in the alternate key in the lookup field, and thereby saving the DBLOOKUP step.

  3. Avatar for Joe D365
    Nilesh
    January 19, 2017

    Hi,
    How Can i retrive alternate key by using SDK.?

  4. Avatar for Joe D365
    Donal McCarthy
    April 4, 2017

    Hi,

    Is it possible to add a lookup to an alternate key?

    Thanks

Leave a reply Required fields are marked *