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
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 (1,561)