cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Community Support
Community Support

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
Community Support
Community Support

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

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

@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.

thank you for help..

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Users online (7,972)