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

return string in a loop

I want to return all product descriptions from an auto-generated email.  

 

Example:

PART NUMBER: 100000

DESCRIPTION : Item No.1

SHIPPED DATE :16-JUL-20

SHIPPED QUANTITY : 1

TRACKING NUMBER : 55555555

PART NUMBER : 10000000

DESCRIPTION : Item No.1

SHIPPED DATE : 16-JUL-20

SHIPPED QUANTITY : 1

TRACKING NUMBER : 5555555

PART NUMBER : 1000000

DESCRIPTION : Item No.3

SHIPPED DATE : 16-JUL-20

SHIPPED QUANTITY : 1 TRACKING NUMBER : 555555

 

In this example only 3 items were shipped but it can be up-to 10 items (generally).

The returned strings will be added to task cards in planner to inform assigned install tech what was purchased.

 

I have been using expressions

Description1Compose: (indexOf('EmailBody'),'DESCRIPTION')

Description1Compose: substring(outputs('EmailBody'),outputs('DESCRIPTION'))

Description1Compose: (indexOf(outputs('DESCRIPION'),'SHIPPED')

Description1Compose: substring(outputs('DESCRIPION'),0,outputs('SHIPPED'))

 

This returns the description of the product only.  I'd like to loop this through to capture all items.

An alternative to running a loop I thought of was if I could add a qualifier like "if" indexOf equals -1 terminate the flow, but I'm not sure how to add it to the expression, or if I should add it in as a step itself in the flow.

 

Any Ideas??? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @RP5,

 

You could try these steps to process the Email body:

1. I copy the instance you provided and store it in the Compose action.

2. Then initialize a string variable by clicking once "Enter" button.

3. Use split() function separates the Email body into an array, the BreakLine variable is the separator.

4. Then use Filter query to filter out item contains "DESCRIPTION : "

Annotation 2020-07-22 152144.jpg

 

Annotation 2020-07-22 152446.jpg

Run results:

Annotation 2020-07-22 152000.jpg

 

Best Regards,
Community Support Team _ Lin Tu
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

3 REPLIES 3
ScottShearer
Super User
Super User

@RP5 

I need to update my solution - will re-post in a few...

 

 

 

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

Scott
v-litu-msft
Community Support
Community Support

Hi @RP5,

 

You could try these steps to process the Email body:

1. I copy the instance you provided and store it in the Compose action.

2. Then initialize a string variable by clicking once "Enter" button.

3. Use split() function separates the Email body into an array, the BreakLine variable is the separator.

4. Then use Filter query to filter out item contains "DESCRIPTION : "

Annotation 2020-07-22 152144.jpg

 

Annotation 2020-07-22 152446.jpg

Run results:

Annotation 2020-07-22 152000.jpg

 

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

It kind of works.

My text as written here contains carriage returns that are lost in the HTML to text conversion.

I have to go back and add the returns at the end of the lines to have it return only the description.

 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (2,131)