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

Extract Data From Email and Create Array Object

Hello,

 

I have a e-commerce email that notifies me of any new orders, like so:

 

ORDER DETAILS

 

SKU 123456

QTY  5

STYLE MLC

COLOR 1 BLUE

COLOR 2 RED

 

I would like to process the order information so as to create an array object named "Order" with the text in bold as keys and the plain text as the values. I can,  in theory, place a delimeter between the two, (i.e SKU | 123456) to help with the split function, but have yet to find a way creat an array object and input the key value pairs as described above.

2 REPLIES 2
ryleybauer
Resolver II
Resolver II

Hi @Mobutu1650 , 

I assume you're using the "when an email comes in" trigger.

 

You won't be able to do keypairs in an array as they're meant to be 1D. A riskier method would be creating 5 arrays and returning the pairings by [position], but I wouldn't recommend that.

 

There's an other variable type "object" which you could use.  Are you familiar with JSON? If the emails are always exactly the same, you could split by spaces and count which objects would be the value in the key-value pairs. Create 5 variables, then you would have an apply to each loop on the split(emailbody,' ') value and a Switch statement (like if, but with many else branches) to get your 5 values and then use a Compose step to build the JSON like this:

{

"SKU": "[value from variable]",

"QTY": "[value from variable]" 

}

 

Then you can set your object variable to the outputs of this Compose step

Mobutu1650
Frequent Visitor

Thanks, but unfortunately, the products in question have a massive amount of options/configurations that make parsing the email content and iterating through all possible if/else conditions somewhat tricky. Wondering if it would be just easier to split the bolded and plain text and throw it in column excel column or list...

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,640)