cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Imrhien
Regular Visitor

Unable to process template language expressions in trim/split action, causing Flow Failure status even if it succeeds

Error is:

 

 

Unable to process template language expressions in action 'Initialise_SubjectTrimmed' inputs at line '0' and column '0': 'The template language expression 'trim(split(split(variables('EmailSubject'),'Issue ')[1],':')[0])' cannot be evaluated because array index '1' is outside bounds (0, 0) of array. Please see https://aka.ms/logicexpressions for usage details.'.

 

 

My code is:

 

 

trim(split(split(variables('EmailSubject'),'Issue ')[1],':')[0])

 

 

 What I'm trying to do:

The code takes the subject from an email and tries to find the text between "Issue " and ":". For example, if the email subject is "Issue 123: something is broken", the output is 123.

 

The problem:

If the Issue text exists, the script functions normally. I have configured a runafter if the above action fails (eg there was no issue text) and the entire script functions. However, this triggers the above error and the flow is considered a failure. Ultimately I don't care about the error as I'm handling it, but this problem is making it hard to debug other errors as it's giving me false positives. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-dezhili-msft
Microsoft
Microsoft

Hi @Imrhien ,

 

Are you trying to split the string by the keyword "Issue"?
I suggest you add a Condition action to compare whether "Issue" is included in the string before splitting.

.
vdezhilimsft_0-1669367107621.png

 

vdezhilimsft_1-1669367107622.png

 

vdezhilimsft_2-1669367107623.png

 

vdezhilimsft_3-1669367107623.png

 

vdezhilimsft_4-1669367107624.png

 


Best Regards,
Dezhi

View solution in original post

4 REPLIES 4
Sundeep_Malik
Community Champion
Community Champion

Hey @Imrhien 

 

Can't test this currently, but try this expression for this:

 

split(split(variables['EmailSubject'],':')[0],' ')[1]

 

So, in the above expression, first I am splitting the string where colon is. Then taking the 0 index value.

 

So, if we take the example 

Issue 123: Error

Then after first split the expression would look like this:

[Issue 123], [Error]

Then in the second split I am taking Issue 123 and splitting it at a space and as I want 123 I am using [1] to extract it.

 

I hope this helps. 🙂

 

 

 

Imrhien
Regular Visitor

Hi Sundeep,

 

That's a cool way to do it - but if the email subject is "Re: Issue 123: error", I assume that this won't work because it'll start parsing at the first colon.

v-dezhili-msft
Microsoft
Microsoft

Hi @Imrhien ,

 

Are you trying to split the string by the keyword "Issue"?
I suggest you add a Condition action to compare whether "Issue" is included in the string before splitting.

.
vdezhilimsft_0-1669367107621.png

 

vdezhilimsft_1-1669367107622.png

 

vdezhilimsft_2-1669367107623.png

 

vdezhilimsft_3-1669367107623.png

 

vdezhilimsft_4-1669367107624.png

 


Best Regards,
Dezhi
Imrhien
Regular Visitor

Thanks Dehzi, that's a great solution. That has solved my problem 🙂 I've re-organised my flow to fit this logic.

 

For anyone else trying this, I also added an IsInteger check afterwards in case someone uses the word "Issue " but doesn't follow it with a number.

 

Imrhien_0-1669583136795.png

 

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.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,732)