cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Oliandril
Advocate I
Advocate I

Using Values in a Flow from JSON Parse

Hi everyone,

I need your support reading / comparing values from my JSON Parse.

My flow reads the last two versions from an Sharepoint List element.

 

This is output Version 1:

{

"LookupId": 21,
"LookupValue": "Thomas Wick",
"Email": "Thomas.Wick@losch.lu"
}

 

This is output Version2

 

{
"LookupId": 6,
"LookupValue": "XXX XXXX",
"Email": "XXX.XXX@losch.lu"
}
 
What I want to do is, to evaluate the latest "LookupID" and compare the e-mail adress from both outputs.
This information is needed to send the an email to the new e-mail adress.
 
I tried different ways but i didn´t find a solution.
 
Thanks in advance,
Thomas

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi again

Let's see if this suggestion matches your requirements. I am assuming you have both objects stored in two different variables, in my example I am calling them 'Object 1' and 'Object 2'

If they are stored in a different structure (array of N objects, etc) please let us know

 

1st evaluate both Email addresses

Condition

equals(variables('Object1')?['Email'],variables('Object2')?['Email'])

 

If true

2nd: identify which Email to be notified (the one whose LookupId is bigger):

Send an email adding the following expression in the Subject, Body...

if(greater(int(variables('Object1')?['LookupId']),int(variables('Object2')?['LookupId']),variables('Object1')?['Email']),variables('Object2')?['Email']))

 

 

Hope this helps

 

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

One last comment

I am doing some tests on my side , and realized the way to identify who is the author of the last item modification is not by means of comparing LookupID's as I understood initially, but by checking "IsCurrentVersion" property that is outside of the Author object structure

So instead of

if(greater(int(variables('Object1')?['LookupId']),int(variables('Object2')?['LookupId']),variables('Object1')?['Email']),variables('Object2')?['Email']))

 

I would suggest to obtain the Author of the current version with another approach

1.- initialize variable

Name: object 1

type: object

Value: setProperty(first(body('JSON_analysieren')?['value'])?['Author']setProperty(first(body('Parse_JSON')?['value'])?['Author'],'IsCurrentVersion',first(body('Parse_JSON')?['value'])?['IsCurrentVersion'])

 

2.-initialize variable

Name: object 2

type: object

Value: setProperty(last(body('Parse_JSON')?['value'])?['Author'],'IsCurrentVersion',last(body('Parse_JSON')?['value'])?['IsCurrentVersion'])

 

3- Expression to get curent Version author email

if(equals(variables('Object1')?['IsCurrentVersion'],bool(1)),variables('Object1')?['Email'],variables('Object2')?['Email'])

 

Flow_SPListItemVersions_1.png

Step 4.- should be the Condition evaluating if both emails are the same, if not you send a notification via email

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

10 REPLIES 10
efialttes
Super User
Super User

Hi

Let me see I understood:

 


What I want to do is, to evaluate the latest "LookupID" and compare the e-mail adress from both outputs.
This information is needed to send the an email to the new e-mail adress.
 

So, from your example, you expect the Flow to select the latest "LookupID" (21 since it is bigger than 6?), and if LookupId21 "Email"  differs from LookupId 6 Email, notify somebody else LookupId 21 email address, right?

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Thats correct. But i cant select the fields directly. And you have to think about that if the Sharepoint element changes, there is a new lookup id.

Hi again

Let's see if this suggestion matches your requirements. I am assuming you have both objects stored in two different variables, in my example I am calling them 'Object 1' and 'Object 2'

If they are stored in a different structure (array of N objects, etc) please let us know

 

1st evaluate both Email addresses

Condition

equals(variables('Object1')?['Email'],variables('Object2')?['Email'])

 

If true

2nd: identify which Email to be notified (the one whose LookupId is bigger):

Send an email adding the following expression in the Subject, Body...

if(greater(int(variables('Object1')?['LookupId']),int(variables('Object2')?['LookupId']),variables('Object1')?['Email']),variables('Object2')?['Email']))

 

 

Hope this helps

 

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Thats the point! If i try to get the Variable I just get the last one. Not the data from the other version.

Hi @Oliandril ,

 

Please you please share a screenshot of the configuration of your flow?

 

Best Regards,

Alice

 

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


@Oliandril wrote:
Thats the point! If i try to get the Variable I just get the last one. Not the data from the other version.

Glad to hear that! Did you manage to fix the problem?



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Here is my flow. Maybe that shows the problem in more detail:

 

flowstep1.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

flowstep2.JPG

 

Now here is the result:

 

result1.JPG

 

value1.JPG

 

value2.JPG

 

To compare this 2 values I need to know how I can read out the specific data "LookupID" and "email" from the JSON parse. 

 

 

 

 

 

Hi again

Both objects are elements of an array.

Since you use top=2 in the HTTP URI, I assume you get max 2 objects in the array.

 

If I were you I would replace Auf alle Anwenden 3 'Apply to each' and use instead

1.- initialize variable

Name: object 1

type: object

Value: first(body('JSON_analysieren')?['value'])?['Author']

 

2.-initialize variabble

Name: object 2

type: object

Value: last(body('JSON_analysieren')?['value'])?['Author']

 

3.- evaluate both Email addresses

Condition

equals(variables('Object1')?['Email'],variables('Object2')?['Email'])

 

Inside true branch

identify which Email to be notified (the one whose LookupId is bigger):

Send an email adding the following expression in the Subject, Body...

if(greater(int(variables('Object1')?['LookupId']),int(variables('Object2')?['LookupId']),variables('Object1')?['Email']),variables('Object2')?['Email']))

 

Hope this helps

Select



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



One last comment

I am doing some tests on my side , and realized the way to identify who is the author of the last item modification is not by means of comparing LookupID's as I understood initially, but by checking "IsCurrentVersion" property that is outside of the Author object structure

So instead of

if(greater(int(variables('Object1')?['LookupId']),int(variables('Object2')?['LookupId']),variables('Object1')?['Email']),variables('Object2')?['Email']))

 

I would suggest to obtain the Author of the current version with another approach

1.- initialize variable

Name: object 1

type: object

Value: setProperty(first(body('JSON_analysieren')?['value'])?['Author']setProperty(first(body('Parse_JSON')?['value'])?['Author'],'IsCurrentVersion',first(body('Parse_JSON')?['value'])?['IsCurrentVersion'])

 

2.-initialize variable

Name: object 2

type: object

Value: setProperty(last(body('Parse_JSON')?['value'])?['Author'],'IsCurrentVersion',last(body('Parse_JSON')?['value'])?['IsCurrentVersion'])

 

3- Expression to get curent Version author email

if(equals(variables('Object1')?['IsCurrentVersion'],bool(1)),variables('Object1')?['Email'],variables('Object2')?['Email'])

 

Flow_SPListItemVersions_1.png

Step 4.- should be the Condition evaluating if both emails are the same, if not you send a notification via email

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Thank you so much for your great and fast support.

I am so happy to know now how I can also update other flows I created in the past.

 

Thanks again!!! 👌👍

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,190)