Upsert-ing a record with CDS connector

By | January 30, 2021

“Common Data Service” connectors don’t have an “Upsert” action:

image

And it would have been a problem for one of the flows I had to implement recently if not for David Yack who pointed out that Update action will do an Upsert.

What??

Well, he was absolutely right, here you go:

Have fun folks. And thank you, David.

4 thoughts on “Upsert-ing a record with CDS connector

  1. bert

    HI Nice solution but I punishing my head to retrieve if a record already exist in the entity… So far I found only a solution to use the ‘List Rows’ action to setup a filter to retrieve one record based on a filter. When Found update otherwise create.
    Using ‘List rows’ action an update action that referencing the outcome of the ‘list row ‘ results in a for each loop with an update action inside. But the for each action is never evaluated if list row action found no match 🙁

    any suggestions ?

    regards Bert

    Reply
    1. Vincent Szabang

      I just do a “List rows” and then create a condition.
      In the condition I put expression : empty(outputs(‘List_rows)?[‘body/value’]) is equal to “true”

      If yes -> Update account (with a random guid, so bascily “create)
      if no -> Update account

      This works just fine….

      Reply
      1. Mehmet Seckin

        While it’s a neat trick, one quick note on this approach; it can impact the performance of your instance in the long run as you shouldn’t arbitrarily create unique identifier for Dataverse records – this could make it more difficult to index and page the data in the background.

        I’d let the platform handle the GUIDs, and look into whether it is possible to use an alternate key instead. Even if an alternate key approach is not possible in a cloud flow, I think the list rows + filter + conditional split is a simple-enough solution to mitigate the performance costs.

        Kind regards,
        Mehmet

        Reply
  2. Rod

    Thanks Alex! That was a great tip and just what I was looking for.

    Reply

Leave a Reply

Your email address will not be published.