Dynamics CRM 2015 Update 1 Series (4): Alternate Keys, dynamicsalternate

Source: Internet
Author: User

Dynamics CRM 2015 Update 1 Series (4): Alternate Keys, dynamicsalternate

Alternate Keys, Or a heavyweight Feature related to system integration. Using this Feature can greatly improve the time cost of developing data integration interfaces and the operation efficiency of interfaces.
In the previousDynamics CRMIn the version, we can only judge the uniqueness of the record through the primary key of the Entity. Now we can useAlternate KeysTo determine the uniqueness of the record. What's more interesting is that we can configure the object's ownAlternate Keys.
Currently, Alternate Key only supports fields of the text and number types, and each object can only be configured with up to five keys. However, this is good and the configuration method is simple:Setting-> Customization-> Entity-> Key

If the input data violates the Alternate Key rule, the system will prompt the following error:

The function has no significant impact on end users. However, for a wide range of developers and system administrators, the function is actually a great feature, this saves the time spent on field ing. The following code snippet demonstrates how to obtain the staff data of an Alternate Key and how to use it to replace Entity Primary Key.

RetrieveEntityKeyRequest req1 = new RetrieveEntityKeyRequest();            req1.LogicalName = "new_accountkeyforerp";            req1.EntityLogicalName = "account";            RetrieveEntityKeyResponse rep1 = CrmSvc_Online.Execute(req1) as RetrieveEntityKeyResponse;            string accountNumber = "2";            string accountName = "Account2";            Entity acc1 = new Entity("account");            acc1.Id=Guid.Parse("{1B9D2BC3-7A0F-4D94-950A-B367D032092F}");            acc1.Attributes.Add("accountnumber", accountNumber);            acc1.Attributes.Add("name", accountName);            UpsertRequest upsertReq1=new UpsertRequest();            upsertReq1.Target=acc1;            CrmSvc_Online.Execute(upsertReq1);            //uses unique key to update/delete account            KeyAttributeCollection keys=new KeyAttributeCollection();            keys.Add("accountnumber",accountNumber);            keys.Add("name",accountName);            Entity acc2 = new Entity("account",keys);            acc2.Attributes.Add("telephone1", "1522222222");            CrmSvc_Online.Update(acc2);            Entity acc3 = new Entity("account", keys);            DeleteRequest req = new DeleteRequest();            req.Target = new EntityReference("account", keys);            CrmSvc_Online.Execute(req);

If your project involves a large number of data interfaces, try this method to design your program.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.