cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
krfajar
Helper III
Helper III

Convert boolean to string in ms flow cannot work

Hi

I've created a flow when an item modified to do approve/reject to the creator of the item. I've field drop down list 'Approve' or 'Reject'.

field approve.png

 

 

 

When I am create initialize variable: with Name: Action, Type: Boolean, Value: true

initialize variable1.png

But when I am add action trigger Switch-Case, my expression in Switch showing error:
The execution of template action 'Switch_3' failed: The result of the evaluation of 'scope' action expression '@body('Update_item_BDE_BDM')?['Approved_x0020__x002f__x0020_Rej']?['Value']' is not valid. It is of type 'Null' but is expected to be a value of type 'String, Integer'.

 

And expression I made is as follows:
coalesce(body('Update_item_sales_approver_BDE_BDM')?['Approved_x0020__x002f__x0020_Rej']?['Value'],'0','1')

expression.png

But my expression result it is not in accordance.

expression result1.png

 

 

 

 

Whether the my expression logic that I made is appropriate? Please advice, Thanks

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

@krfajar

The coalesce expression returns the first non-null value it sees. So, in you expression, if no value has been selected, the next value it sees is approved.  So, it will always return approved if no value is selected.  Please see my example above for another way to approach your issue.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

 

Hi @krfajar ,

 

As @ScottShearer  suggested, you could also check the example in this online doc and get more details about this function:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#c...

 

Best Regards,

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

5 REPLIES 5
Gristy
Resident Rockstar
Resident Rockstar

your value is null, it needs a value.

ScottShearer
Super User III
Super User III

@krfajar 

Without seeing more detail it is hard to tell you exactly how to fix your issue.  However, my example below show how you could approach this issue.  I have a list with a choice column called My Choice.  There is no default value and available choices are Approve and Reject.   My switch statement contains a coalesce expression - the expression can be seen in the action comment area.  The expression output will be Accept or Reject of one of those two is selected.  If no option is selected, the output will be "No Selection".

NullChoice1.jpg

Are you sure that the screen shots you have provided are where the error is occurring?  The screen shot shows the switch name as Switch and the error references Switch_3.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Hi @ScottShearer 

Sorry, my showing error after I am add action trigger "initialize variable".

 

But now when I am change my expression to be:

coalesce(body('Update_item_sales_approver_BDE_BDM')?['Approved_x0020__x002f__x0020_Rej']?['Value'],'Approved','Rejected')

 

My problem now is when I have not chosen the choice between 'approve' or 'reject' why my flow is Approved?

Is there something wrong with my expression?

 

Thanks before..

@krfajar

The coalesce expression returns the first non-null value it sees. So, in you expression, if no value has been selected, the next value it sees is approved.  So, it will always return approved if no value is selected.  Please see my example above for another way to approach your issue.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

 

Hi @krfajar ,

 

As @ScottShearer  suggested, you could also check the example in this online doc and get more details about this function:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#c...

 

Best Regards,

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

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (86,894)