Hello @Harmsolo
If you subject is is in the same format as what you provided
**** OUTAGE - CAD MONTHLY Outage - Thursday 5th October - 0130 hrs to 0500 hrs *****
Extracting the Issue
You can use split() to divide the string at ’ - ’ and take the first part.
split(triggerBody()?['subject'], ' - ')[0]
This expression splits the subject line at ’ - ’ and takes the first part, which should be your issue.
Extracting the Start Date and Time
Since the date and time format seems consistent, you can use substring() along with indexOf() to extract the start date and time.
substring(triggerBody()?['subject'], indexOf(triggerBody()?['subject'], ' - ')+3, 22)
This expression finds the first ’ - ’ in the subject, then takes a substring starting three characters after that up to the length of the date and start time string.
Extracting the End Time
The end time can be extracted similarly, but you’ll need to find the ‘to’ part.
substring(triggerBody()?['subject'], lastIndexOf(triggerBody()?['subject'], 'to ') + 3, 5)
This extracts the end time part of the string.
Remember, these expressions assume a consistent format in the email subject line. If the format varies significantly, you might need more complex logic or regular expressions to handle those cases.
TEST TEST.