Retrieving metadata items by name is generally easier because you probably already have some reference to this item name in your code. The following table lists the alternate key properties for retrieving metadata items by name. The primary benefit of this feature is to provide an alternative way to identify a CRM record.
Traditionally we use CRM entity’s primary key field to identify a CRM record, which stores GUID values and this becomes a challenge when we try to integrate CRM data with third-party database or application systems, which might use some natural keys to identify a record. It provides much easier way to code while integrating with 3rd party systems.
Metadata item | Alternate Key | Example |
Entity | LogicalName | GET /api/data/v8.2/EntityDefinitions(LogicalName=’account’) |
Attribute | LogicalName | GET /api/data/v8.2/EntityDefinitions(LogicalName=’account’)/Attributes(LogicalName=’emailaddress1′) |
Relationship | SchemaName | GET /api/data/v8.2/RelationshipDefinitions(SchemaName=’Account_Tasks’) |
Global Option Set | Name | GET /api/data/v8.2/GlobalOptionSetDefinitions(Name=’metric_goaltype’) |
When creating an alternative key, CRM kicks off a system job that creates a db index at CRM database server side, the purpose of the db index is to enforce the uniqueness of key while offering an optimal query performance. Depending on the number of existing CRM records that you have for the concerned entity in CRM system, it could take a while to create the index. You can see the most recent status of the index creating job. Only the below three fields could be created as keys and over all we can create 5 keys for an entity.
- String
- Integer
- Decimal
Alternate keys could be used in the two scenarios as below
- Update
- Upsert (a new capability introduced in CRM 2015 Spring release, which will be further discussed in a following post)
Let us see performing an update operation through code with alternate keys
|
In the case that a CRM record cannot be found using the provided key value, you will receive the following error exception (where account is the entity name).
References: Alternate keys from MSDN
Cheers,
PMDY
What are the alternative options for GET /api/data/v8.2/EntityDefinitions(LogicalName=’account’) in dynamics 2015/2011
LikeLike
A GET operation is basically required to fetch data, what exactly you were looking for?
LikeLike
Wow! This could be one particular of the most useful blogs We have ever arrive across on this subject. Actually Fantastic. I am also a specialist in this topic so I can understand your hard work.
LikeLike