cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ivan_stricek
Level: Powered On

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

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

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

ivan_stricek
Level: Powered On

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

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.
ivan_stricek
Level: Powered On

Re: Calculate variable by Compose

thank you for help..

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

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!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (4,485)