Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Utilizing Alternate Keys in Dynamics CRM Integrations

Post Author: Joe D365 |

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!

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!

Joe CRM
By 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.

6 comments on “Utilizing Alternate Keys in Dynamics CRM Integrations”

  1. 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. 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

    1. 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.

      1. 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.

PowerObjects Recommends