Hi All,
I've been struggling to extract varied specific text contained within this email subject:
Plan completed for Site title: Test Site | Org: BBC | Site Type: Team | Form Status: Complete form | SRS: OFFICIAL - Team or Group | MyIQ_No: 1000A||
variable 1 = need to extract and assign it: 1000A
variable 2 = need to extract and assign it: Test Site
variable 3 = need to extract and assign i: OFFICIAL - Team or Group
etc
tried these variations and they don't work:
last(split(first(split(triggerBody()?'subject','||')),'MyIQ_No: '))
last(split(first(split(triggerBody()?['subject'],'||')),'MyIQ_No: '))
Please kindly help?
Thanks in advance
SKooLZ
Thank you all for generous replies to my query, much appreciated! I only managed to test and implement Eliotcole's solution as it was simpler for me to follow and apply and it worked a charm. So the other solutions may work similarly but I didn't test them but thank you all again for your kind assistance with this!!
If you can confirm that the subject line will always be formatted that way, but might contain new fields, then this is a bit more complicated, but will put it all in a JSON object, and you won't be at the mercy of whatever is creating that email subject maybe changing the field names.
As always, though, remember that when working with text strings you are always at the mercy of the string formatting.
setProperty(json(replace(replace(replace(replace(variables('emailSubjectVAR'), 'Plan completed for ', '{"planStatus":"empty","'), ' | ', '","'), ': ', '": "'), '||', '"}')), 'planStatus', first(skip(split(variables('emailSubjectVAR'), ' '), 1)))
This does a few things;
Here's the imagery:
To differ from Eric's excellent solution only slightly, I would split on the actual words, then you can save the Apply to each action.
trim(first(split(last(split(EMAIL_SUBJECT, 'FIELD_NAME')), '|')))
In my example, below, you can see I had to assume that my input was a variable called emailSubjectVAR, you can either use that or simply place the email subject there using the dynamic data instead of the variable.
All that expression is doing is:
Hi @SkoolZ ,
You can try a normal split(xxx, '|') into an array, loop through the array and if the value contains MyIQ_No, save to a variable and repeat for all your values. You can also reference the index of the array if you dont want to loop.
--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up
Connect on LinkedIn
WarrenBelz
146,731
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,075
Most Valuable Professional