Skip to main content
Community site session details

Community site session details

Session Id : oj9xSIkAlafX7pxR1oCbHE
Power Apps - Microsoft Dataverse
Unanswered

UpsertRequest

Like (0) ShareShare
ReportReport
Posted on 20 Nov 2021 10:59:38 by

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

Categories:
  • EricRegnier Profile Picture
    8,714 Most Valuable Professional on 21 Nov 2021 at 07:39:04
    Re: UpsertRequest

    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!

  • Ram Prakash Profile Picture
    5,318 Super User 2025 Season 2 on 20 Nov 2021 at 18:51:16
    Re: UpsertRequest

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Featured topics