Hi all, I am new to power automate as its not something we as a company have needed until now. I am learning it as i go but i am stuck on how to do something and hoping someone can help.
I have set up a flow that checks emails as they arrive as we get them from several locations and cant alter the subject but all the emails contain the company name within the subject, the flow looks in the subject for certain words, then if one of the words appears it sends an email, I send the email with a specific subject and add the subject and body of the original email to the new email (this is a ticketing email account so emails with the Subject of the company get a ticket created automatically hence why i am doing this). If one of those words is not there then a false statement checks for another set of words and does the exact same same and so on and so on until its finished checking.
Now i have to do this 30+ times (so check for each company we support) see image below for example of how i am currently doing this
What i would like to do is put all the different words into one contains list and then send a new email with the subject of the name it finds from the contains list.
I can do the contains list and i can do the body of the email but getting the subject to be the name of the company it finds from the contains list seems to be failing me and cant see a way to do it.
Any help would be appreciated.
Solved! Go to Solution.
Hi!
Havent tested myself, but maybe you can add all patterns (i.e. words) in an array variable:
Add an Initialize variable action block, let's call the variable myPatternDictionary, type array, value:
[
"word1",
"word2",
"word3"
]
So in the example I am searching for 3 patterns (word1, word2, word3), but you can add any number you need
NExt, add a 'Filter array' action block, assign as its input 'myPatternDictionar' variable. Now on the left side of its condition rule, add 'Subject' from the dynamic content menu. SElect operator 'contains'. On the right side of its condition rule, add the following expression:
item()
Next add a Condition action block, on the left side of its condition rule, add the following expression:
length(body('Filter_array'))
SElect 'greater than' as operator
Now, on the right side of its condition rule, add the following value
0
Flow execution will take the true branch if any of the patterns is found in the Subject... so on the true branch you should add the notification logic.
Please also note 'Filter array' output is an array also, with as many alements as patterns found in the subject. Assuming you can find either 0 or 1 pattern max., you can get the first pattern foundin the Subject by means of the following expression:
first(body('FilterArray'))
If you are not familiar with expressions, please follow these steps to add them:
https://flow.microsoft.com/es-es/blog/use-expressions-in-actions/
Hope this makes sense
Proud to be a Flownaut!
Hi!
Havent tested myself, but maybe you can add all patterns (i.e. words) in an array variable:
Add an Initialize variable action block, let's call the variable myPatternDictionary, type array, value:
[
"word1",
"word2",
"word3"
]
So in the example I am searching for 3 patterns (word1, word2, word3), but you can add any number you need
NExt, add a 'Filter array' action block, assign as its input 'myPatternDictionar' variable. Now on the left side of its condition rule, add 'Subject' from the dynamic content menu. SElect operator 'contains'. On the right side of its condition rule, add the following expression:
item()
Next add a Condition action block, on the left side of its condition rule, add the following expression:
length(body('Filter_array'))
SElect 'greater than' as operator
Now, on the right side of its condition rule, add the following value
0
Flow execution will take the true branch if any of the patterns is found in the Subject... so on the true branch you should add the notification logic.
Please also note 'Filter array' output is an array also, with as many alements as patterns found in the subject. Assuming you can find either 0 or 1 pattern max., you can get the first pattern foundin the Subject by means of the following expression:
first(body('FilterArray'))
If you are not familiar with expressions, please follow these steps to add them:
https://flow.microsoft.com/es-es/blog/use-expressions-in-actions/
Hope this makes sense
Proud to be a Flownaut!
Hi @JamesWaugh ,
If one Condition would only check one value, and the value would be the subject or the new email, your requirement could be achieves with the containlist.
However, since each condition on your side would check 2 or 3 values, I think it couldn't be achieved with the containlist.
Best regards,
Alice
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for that, all working perfectly and doing as it should. I will no doubt be looking at upgrading this in the future but for now its working as we need it. Thanks again.
User | Count |
---|---|
88 | |
43 | |
21 | |
18 | |
16 |
User | Count |
---|---|
132 | |
47 | |
42 | |
36 | |
28 |