cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Player1
Frequent Visitor

Invalid template indexOf

I started off with using compose but Im getting this error on test so I tried variable but wasn't helpful, you guys have any idea where I might have overlooked things?

 

substring(variables('TxtEmailBody'),indexOf(variables('TxtEmailBody')),variables('DomainName'),9)

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

 

Hi @Player1 ,

 

Please try the following configuration and expression:

7.PNG

trim(split(split(outputs('Html_to_text')?['body'],'date')[1],'domain')[0])

Feel free to let us know if you have any questions about this method.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
manuelstgomes
Super User II
Super User II

Hi @Player1 

 

I think you have too many parameters.

 

The substring needs 3 parameters:

1. text: string

2. startIndex: integer

3. length?: integer

 

You have the variables('DomainName') that is a, I supose, a string and then a 9 so you have 4 parameters.

 

What do you want to do with variables('DomainName')?

 

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

Cheers
Manuel

Thanks for the quick response @manuelstgomes, I though it won't let me save the flow if I have too much parameters and though that I have the right parameters in place:

 

Capture.JPG

 

 

Hi @Player1 ,

 

Could you provide us with sample data of the email body so that we can provide you with a suitable expression to extract the specified data?

 

Does the content of the Email body have a fixed format? Please consider following these similar threads and see if it helps:

Solved: Extracting text from email - Power Platform Community

 

Solved: Extract text from body of an email and create new ... - Power Platform Community

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HI @Player1 

 

The indexOf is not what you present in your graphic. Check the parenthesis. Here's the start and end of the indexOf.

Capture.png

 

That's why you get the error. You have four parameters and not 3. 

 

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

Cheers
Manuel

Hi @v-bacao-msft this is how the email body looks like after converting it to txt, my goal on this expression is to get the 9 digit number on it:


date

234234354

domain[.]net

This domain does not resolve

astrata

2020-08-03

 

I split it previously and got the 'domain' as dynamic content. 

 

 

Hi @Player1 ,

 

Please try the following configuration and expression:

7.PNG

trim(split(split(outputs('Html_to_text')?['body'],'date')[1],'domain')[0])

Feel free to let us know if you have any questions about this method.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @v-bacao-msft and @manuelstgomes

 

Thank you very much for your inputs and apologies for not responding back quickly but playing around with with flow and what I was trying to achieve have made me realize that my original concept was not reliable if I receive multiple data that I would like to extract/match on a single email body. Hence keep at it and found a more robust approach to go about it and its by using regex to match the data that I want, with patterns.

 

This might be outside the context and subject of my original post but would like to give an update on my journey with power automate as people might be in a similar position. So I receive these emails and its the trigger of my flow converting them from html to text this is how they look:


Registration date

 

123456789

 

blog[.]domain[.]fm

 

2020-08-09

 

223456789

 

domain[.]de

 

2020-08-09

 

now the data that is relevant to me is the nine digit ticket number and their domains. I'm able to parse and match them using plumsail match regular expression:

 

\d{9}|(?<=\d{9}\n\n)\w.*

 

the first part \d{9} matches the nine digit ticket number that I need and the | is OR operation and the last part (?<=\d{9}\n\n)\w.* is matching the domain reported and gives me an output:

 

[
{
"Match0": "123456789"
},
{
"Match0": "blog[.]domain[.]fm"
},
{
"Match0": "223456789"
},
{
"Match0": "domain[.]de"
}
]

 

The problem Im getting now is to actually use the data that I'm matching. As each ticket number and domain are a new match0 using it on apply for each is proving harder than advertised because I want to edit a list that has the Domain with the corresponding TicketNumber in a single row, this is how the data structure of the list looks like:

 

Player1_0-1598271661684.png

 

I tried the named groups which looks easy in some post using the following regex:

 

TicketNumber: (?<TicketNumber>\d{9})
Domain: (?<Domain>(?<=\d{9}\n\n)\w.*)

 

But I'm not getting any matches with this expression and returning as false.

 

 

 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,327)