cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ML147243
Helper II
Helper II

Using if(contains) statement in update item.

Hello,

 

I am still learning this correct formatting and syntax for this system. I have a list with multiple columns and shown. I would like to add a Role column that updates based on the class that was selected. My current flow works for the function in the Totals for class, so it is likely how the If statement is written. I get an error message about the number of characters.

Any help is appreciated. Thank you.

list.jpg

flow update.jpgedited to add a better picture of If statement.

 

if statement.jpg

  

1 ACCEPTED SOLUTION

Accepted Solutions

My guess would be that you're missing one or more closing brackets. Try to put the whole expression in some code editor, e.g. 'Visual Studio Code' to check if every opening bracket has also a closing bracket.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

5 REPLIES 5
tom_riha
Super User
Super User

Hello @ML147243 ,

the if(...) should be entered as an expression, not as a string.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

@tom_riha Hi Thanks,

Yes, I have tried to enter it as an expression and I get that the expression is invalid. 

My guess would be that you're missing one or more closing brackets. Try to put the whole expression in some code editor, e.g. 'Visual Studio Code' to check if every opening bracket has also a closing bracket.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
ML147243
Helper II
Helper II

So it was that I was using " instead of ' . The flow isn't working though, I tried changing class to class value but it still is not working. 

after some tweaking, this was what worked,

 

if(contains(triggerBody()?['Class/Value'],'EDM RN'),'RN',

if(contains(triggerBody()?['Class/Value'],'Tech'),'CNA',

if(contains(triggerBody()?['Class/Value'],'CNA'),'CNA',

if(contains(triggerBody()?['Class/Value'],'HUC'),'HUC',

if(contains(triggerBody()?['Class/Value'],'SIS RN'),'RN',

if(contains(triggerBody()?['Class/Value'],'RN'),'RN',

if(contains(triggerBody()?['Class/Value'],'HF'),'RN',

if(contains(triggerBody()?['Class/Value'],'student'),'SN',

if(contains(triggerBody()?['Class/Value'],'SCM RN'),'RN',

If(contains(triggerBody()?['Class/Value'],'Athena'),'HFMG','other'))))))))))

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (3,167)