cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stephenJames
Resolver I
Resolver I

Parse string from Email subject between two points

Hello,

         I'm having a little trouble with what the right expression is to grab a string from between two points in an email subject.

The Subject of the emails that i have coming in are as follows as an example

"New Email (Text Word) has come in"

 

What i am trying to do is grab the string between ( and ) 

I have this as the expression but it keeps failing stating that the length cannot be negative. 

substring(triggerbody()?['Subject'],add(indexOf(triggerbody()?['Subject'],'('),1),sub(lastIndexOf(triggerbody()?['Subject'],')'),add(indexOf(triggerbody()?['Subject'],')'),1)))

I have had a look at some of the other posts that talk about parsing text from an email subject but i couldnt get those suggestions to work for me.

Can someone tell me what i am doing wrong in my expression.

2 ACCEPTED SOLUTIONS

Accepted Solutions
stephenJames
Resolver I
Resolver I

I found the error in my expression i had a ) where i should have had a (

Heres the correct expression that is working

 

substring(triggerbody()?['Subject'],add(indexOf(triggerbody()?['Subject'],'('),1),sub(lastIndexOf(triggerbody()?['Subject'],')'),add(indexOf(triggerbody()?['Subject'],'('),1)))

View solution in original post

Pstork1
Dual Super User III
Dual Super User III

You might try spliting the string on the '(' and ')' something like this

First(split(last(split(triggerbody()?['Subject'],'(')),')'))


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

6 REPLIES 6
stephenJames
Resolver I
Resolver I

I found the error in my expression i had a ) where i should have had a (

Heres the correct expression that is working

 

substring(triggerbody()?['Subject'],add(indexOf(triggerbody()?['Subject'],'('),1),sub(lastIndexOf(triggerbody()?['Subject'],')'),add(indexOf(triggerbody()?['Subject'],'('),1)))

View solution in original post

Pstork1
Dual Super User III
Dual Super User III

You might try spliting the string on the '(' and ')' something like this

First(split(last(split(triggerbody()?['Subject'],'(')),')'))


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post


@Pstork1 wrote:

You might try spliting the string on the '(' and ')' something like this

First(split(last(split(triggerbody()?['Subject'],'(')),')'))

Thanks @Pstork1 that seems to be a much simpler solution. 

Hi @Pstork1

 

Sorry to come back to an old thread. I'm trying to achieve pretty much the same setup, however I am trying to use a previous 'Initialise Variable' step in the flow as the reference point in the next 'Initialise Variable', where the email subject will be broken off. I basically require the last string of an email subject broken off, starting with the 8th word in the string, ending with up to the 20th word in the string. 

 

This is the expression I am currently having issues with: 

first(split(last(split(triggerbody(variables('CR Number'))?['Subject'],'CR Number')),')'))
 
& this is the error I'm currently receiving: Unable to process template language expressions in action 'Initialize_variable_4' inputs at line '1' and column '2799': 'The template language function 'triggerbody' must not have any parameters.'.
 
Any help would be greatly appreciated!! 
 
Thanks, 
 
Joe 

 

Pstork1
Dual Super User III
Dual Super User III

Build out your formula using the Dynamic Content tab and the Expressions Tab.  You will find that the Variables object is addressable on its own without using TriggerBody().  That's why you are getting the error.  Just start your formula on the expressions tab and then click back to the Dynamic Content tab when you need to add a specific piece of content  You can go back and forth several times.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thanks for the reply. 

 

I came up with this using the method you advised & its doing the trick: 

 

last(split(triggerBody()?['subject'], variables('CR Number')))
 
Thanks for your help. 
 
Joe

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (81,475)