cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Calculate variable by Compose

Hello,

I would like to ask how I can use finction if in Compose or Switch action.

If I put into Compose @if(empty(triggerBody()?['OData__x0070_jm1']?['Email']),'2','1') and then in email body use the compose output component, I have in message string"@if(empty(triggerBody()?['OData__x0070_jm1']?['Email']),'2','1')" not the result, which should be 2 or 1.

The same is if I want to use this expression in Switch - looks like no value like 2 or 1 is returned.

 

Is there some problem? Can I somhow retriew the result value? And is possible to use empty check on element of Person email field?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Calculate variable by Compose

Hi @ivan_stricek,

 

If you would like to use Compose Action, the input should be double quoted:

"@if(empty(triggerBody()?['OData__x0070_jm1']?['Email']),'2','1')"

And yes, the empty function would work here.

87.PNG

88.PNG

For the Switch Action, use the Compose Output as the parameter. 

Please note: If 1 and 2 are single quoted under the if functiion as the Compose Input, then when use compose output in Switch, the Equal value should be:

"2"

or 

"1"

89.PNG

If you would like to use 2 instead of "2", change the Compose input with the formula below:

"@if(empty(triggerBody()?['OData__x0070_jm1']?['Email']),2,1)"

90.PNG

Regards

Community Support Team _ Michael Shao
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

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: Calculate variable by Compose

Hi @ivan_stricek,

 

If you would like to use Compose Action, the input should be double quoted:

"@if(empty(triggerBody()?['OData__x0070_jm1']?['Email']),'2','1')"

And yes, the empty function would work here.

87.PNG

88.PNG

For the Switch Action, use the Compose Output as the parameter. 

Please note: If 1 and 2 are single quoted under the if functiion as the Compose Input, then when use compose output in Switch, the Equal value should be:

"2"

or 

"1"

89.PNG

If you would like to use 2 instead of "2", change the Compose input with the formula below:

"@if(empty(triggerBody()?['OData__x0070_jm1']?['Email']),2,1)"

90.PNG

Regards

Community Support Team _ Michael Shao
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

Highlighted
Advocate II
Advocate II

Re: Calculate variable by Compose

Yes double quotes, thank you. It is little confucing if I have to use double quotes in Compose but not in advance Condition.

One more question, is possible to change code in Copmpose component after saving? It becomes gray and if I need to change a code little bit, I have to delete rest of workflow with this component and create it again, because gray part is not possible to change..

 

Thank you

Community Support
Community Support

Re: Calculate variable by Compose

@ivan_stricek,

 

No, it is not available to edit it for formula used under Compose, which currently is a limitation.

Please consider submit this as an idea if you would like the Compose Input to be editable after saving.

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

regards

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Advocate II
Advocate II

Re: Calculate variable by Compose

thank you for help..

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

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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
Users online (11,220)