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

Avoid writing multiple variables using Parse JSON (or any other action)

Hello, I'm currently building a flow with teams' approval.

Depending on a sharepoint list value, the approvers will be different.

For example, if the departments concerned are football and fitness, the approval will be sent to each chief.

Instead of setting new variables, I'd like to know how to put together the if expressions.

 

Capture3_LI (3).jpg

 

 

 

 

Capture000.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

if(contains(body('Get_items')?['Department'],'Football'), 'footballboss@@.com', '')
if(contains(body('Get_items')?['Department'],'Basketball'), 'basketballboss@@.com', '')
if(contains(body('Get_items')?['Department'],'Handball'), 'handballboss@@.com', '')
if(contains(body('Get_items')?['Department'],'Hockey'), 'hockeyboss@@.com', '')
if(contains(body('Get_items')?['Department'],'Fitness'), 'fitnessboss@@.com', '')
if(contains(body('Get_items')?['Department'],'Others'), 'othersboss@@.com', '')
 

 

Capture2.PNG

 

 

Still thinking how to get the true values from Parse JSON

 

Finally getting the compose to "Assigned to field"

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hey,

 

Here is the final flow.

Don't forget to use the Parse JSON "Generate from sample" with your compose output.

Capture444.PNGCaptur445e.PNG

 

Thank you so much @abm

View solution in original post

8 REPLIES 8
Highlighted
Super User III
Super User III

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hi @pedrosf 

 

I am not sure about the JSON If statements you mentioned. You could do this via switch action step.

 

Declare a string variable called email. Then retrieve the items using Get Items. Add a switch action step to determine the category and store the email under the new variable. Finally send email using the variable which will have the email address.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Highlighted
Frequent Visitor

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hello @abm

 

Thank you for answering my request.

 

Capture111.PNGCapture112.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I've already flow with a switch setup but I dont'know if the cases "Equals" field triggers if the sharepoint values are written like this.

Capture3_LI (3).jpg

Highlighted
Super User III
Super User III

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hi @pedrosf 

 

Here it is

 

image.png

 

Above the Parse JSON is as follows:

 

{
    "type""array",
    "items": {
        "type""string"
    }
}
 
Thanks


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Highlighted
Frequent Visitor

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hello, 

 

Capture223.PNG

 

 

 

I tried for the last 3 hours to get this through but the "Equal" field doesn't detect the words in the "Expression result". 

It always goes to default.

(To get the "Outputs" in Parse JSON content filed, I had to put the dynamic content in Compose after)

Capture222.PNG

Highlighted
Super User III
Super User III

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hi @pedrosf 

 

I am pretty sure you are mapping the wrong mapping in your switch

 

image.png

 

See my mapping

 

image.png

 


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Highlighted
Frequent Visitor

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hello,

 

That screenshot you mentioned is the result of the flow.

I have the same thing as you.

Capture224.PNG

Highlighted
Super User III
Super User III

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hi @pedrosf 

 

Thanks for the screen share. All we did is rearranged the flow similar like my earlier screenshot.

 

1. Extract the values from SharePoint

2. Parse JSON

3. Iterate each values

4. Switch 

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Highlighted
Frequent Visitor

Re: Avoid writing multiple variables using Parse JSON (or any other action)

Hey,

 

Here is the final flow.

Don't forget to use the Parse JSON "Generate from sample" with your compose output.

Capture444.PNGCaptur445e.PNG

 

Thank you so much @abm

View solution in original post

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (5,015)