Jun 26 2022 07:16 PM
I am using Power Automate to save emails and attachments into a SharePoint Document Library. This is working well, and I now want to automatically apply metadata to the items that are uploaded.
I want to check the Subject field of an email I receive and if it contains a keyword, apply that keyword to the sharepoint column metadata.
I have more than 8 options so I can't use nested conditions (however using conditions DOES work). I am looking to use a switch case with nested if statements, but I am not sure how to refer to the "Subject" field inside an if statement.
For example, in the "On" field in a switch condition: (screenshot below)
if(contains(variables('Subject'),'jeff'),'1',if(contains(variables('Subject'),'josh'),'2',
Is not accepted by the expression field.
Any idea what I'm doing wrong?
Jun 26 2022 11:27 PM
I realised I had syntax problems with my expression. I have now got this line accepted:
if(or(contains(variables('Subject'),'keyword1','1'),variables('Subject'),'keyword2','2'))
However now when I try to save I see this error message:
"Flow save failed with code 'InvalidVariableOperation' and message 'The inputs of workflow run action 'Switch' of type 'Switch' are not valid. The variable 'Subject' must be initialized before it can be used inside action 'Switch'.'."
So many question remains...can I use the dynamic content "Subject" from a "when an email arrives" block in an if expression?
Jun 27 2022 01:47 AM
Jun 27 2022 03:24 PM
Solution