Example of Upsert with Alternate Key
Just thought of sharing one of my learnings when I was working with WebAPI integration work in which we were trying to sync the leads to MS Dynamics CRM from another source. The challenge was that we wanted to use a composite Alternate key which has multiple fields (string and option-set) dataset values.
Note: Xrm.WebAPI. methods don't support patch requests for alternate keys.
Below is the example in which I have passed an alternate composite key in the Patch request and the values we are trying to update in the lead entity object.
To Create an alternate key in Dynamics CRM you can follow the below steps:
- Go to https://make.powerapps.com > Envrionment> Your Solution >Entity > Keys
- Select New key
- On the form, fill in the required fields (Display Name and Name) and then select and add the fields to the key.
- Save the key.
I'll not go in deep regarding alternate key concepts. In our case alternate Composite Key is: new_producttype+emailaddress1+firstname+lastname+mobilephone
Note: Just make sure while patch request alternate key values should match with entity object field values. It should be same otherwise it will not work
Please leave your valuable feedback!!
*This post is locked for comments