cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mirzam
Frequent Visitor

How do I compare json to lists and find if there are records ?

Hi,

I have a json list with clients from another system, this i want to add to the Contact in Dynamics 365 if they don't exists. If they do, i want to update the records. Somehow i'm not able to get the loops to work or getting the criterias to match. I'm using eksternalid in Contact and similiar a wp_user_id in the json. Can somebody help ?? Been stuck for 4-5 hours now.

 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @mirzam,

 

Please not update a record or create a new record in the first condition action. The first condition simply determines whether an item in the ListA matches an item in the ListB, but there may be other item matches in the ListB. So it is unwise to decide whether to update record or add record in a single judgment, which can result in a large number of duplicate item being created.
You can initialize an integer variable called Flag, to set the initial value of 0. It means no item match was found. In the inner loop, if the ListA matches any item, in the ListB, the Flag is set to 1. Then, after the end of the memory loop, create a second Condition action, to determine whether the value of Flag is 1. If it is 1, then restore the Flag to the original value after the update record, update so that the next external loop. If it is 0, it means that there is no value in the ListB to match it, and then add record.

Here is an example:

Screenshot 2020-10-19 113643.jpg

 

Screenshot 2020-10-19 113703.jpg

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-litu-msft
Community Support
Community Support

Hi @mirzam,

 

Please not update a record or create a new record in the first condition action. The first condition simply determines whether an item in the ListA matches an item in the ListB, but there may be other item matches in the ListB. So it is unwise to decide whether to update record or add record in a single judgment, which can result in a large number of duplicate item being created.
You can initialize an integer variable called Flag, to set the initial value of 0. It means no item match was found. In the inner loop, if the ListA matches any item, in the ListB, the Flag is set to 1. Then, after the end of the memory loop, create a second Condition action, to determine whether the value of Flag is 1. If it is 1, then restore the Flag to the original value after the update record, update so that the next external loop. If it is 0, it means that there is no value in the ListB to match it, and then add record.

Here is an example:

Screenshot 2020-10-19 113643.jpg

 

Screenshot 2020-10-19 113703.jpg

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This helped me a lot in my current Flow thank you 🙂

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,701)