Hello Experts,
I have a data integration project(From F&O -> CRM), in powerapps. The integration only inserts the record based on the primary key. I want to insert the record if not available and update the record if it is already available, how do I use the upsertRequest.
Regards
Martin
Hi @martinarul, possible to ellaborate a little on the integration method you're using to insert records from F&O? Suggest havig a look at the out-of-the-box integration with LCS: https://docs.microsoft.com/dynamics365/fin-ops-core/dev-itpro/power-platform/enable-power-platform-integration
Hope this helps!
Hello @martinarul,
You can try below code
// KEY ATTIBUTE COLLECTION --> LIKE DUPLICATE CHECK
KeyAttributeCollection altKey = new KeyAttributeCollection();
altKey.Add("firstname", "Bob");
altKey.Add("lastname", "Smith");
Entity contact = new Entity("contact", altKey);
contact["firstname"] = "Bob";
contact["lastname"] = "Smith";
contact["jobtitle"] = "CEO";
UpsertRequest request = new UpsertRequest()
{
Target = contact
};
UpsertResponse response = (UpsertResponse)service.Execute(request);
if (response.RecordCreated)
Console.WriteLine("Record created");
else
Console.WriteLine("Record updated");
}
Note:
In the above example altKey will check if already available, if yes it will Update the Record else Create the Record that's it 🙂
You can get more details here :
https://carldesouza.com/using-upsert-in-c-dynamics-365/
Please mark as Answer if it is helpful and provide Kudos
Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
Blog : https://microsoftcrmtechie.blogspot.com
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473