Creating a list from multiple xml files

Post Reply
wkopp
Newbie
Posts: 13
Joined: Mon Sep 16, 2019 8:20 pm

Creating a list from multiple xml files

Post by wkopp »

Hello all,

We get xml shipping notifications for each package of an order. I'd like to take the tracking numbers from each of those xml's and include them in a single email notification to the customer. Not sure how to get started on this one. Any ideas?
mkayyyy
Member
Posts: 80
Joined: Mon Nov 21, 2016 6:31 pm
Location: UK

Re: Creating a list from multiple xml files

Post by mkayyyy »

Have you got an example of the XML format?

My initial thought is that you’d need to use the Assemble job element with a custom assembly scheme so you can trigger a single email
wkopp
Newbie
Posts: 13
Joined: Mon Sep 16, 2019 8:20 pm

Re: Creating a list from multiple xml files

Post by wkopp »

Here's a sample of the xml file. Underlined info will change for each package, other info will be common for each order. Number of packages per order will vary.

<?xml version="1.0"?>
<order_status_message>
<internal_order_id>12345678</internal_order_id>
<partner_order_id>OrderID</partner_order_id>
<order_status>Shipped</order_status>
<status_datetime>20230424104520</status_datetime>
<carrier_name>UPS</carrier_name>
<tracking_number>1ZV7V9670399999999</tracking_number>
<ship_method>UG</ship_method>

<merchant_number>55555</merchant_number>
<cobrand_id>Generic</cobrand_id>
</order_status_message>
loicaigon
Advanced member
Posts: 379
Joined: Wed Jul 10, 2013 10:22 am

Re: Creating a list from multiple xml files

Post by loicaigon »

I would second mkayyyy but you would probably need to know the number of items in the order as well so Switch know exactly when to stop waiting for additional xml files and moves to sending email.
wkopp
Newbie
Posts: 13
Joined: Mon Sep 16, 2019 8:20 pm

Re: Creating a list from multiple xml files

Post by wkopp »

Thanks for the input. The number of items will vary. Sometimes it's one box, sometimes it's 20. But they'll all be done at the same time, so I figure waiting for 10-15 minutes should give enough time for all items to process. I can filter by the Order ID so that part is pretty straight forward.

I'm going to make a text file template and use string replace to add the tracking numbers. I think I can get that to work. I was hoping someone had run into this type of thing before and had a better idea.

I'll post a sample of my idea when I get it put together...
wkopp
Newbie
Posts: 13
Joined: Mon Sep 16, 2019 8:20 pm

Re: Creating a list from multiple xml files

Post by wkopp »

I was able to get this working by spreading out the xml files, grabbing an html template, and using string replace to add in the tracking links. After a few minute wait, I use the html template to send the email, then delete it. If anyone has a similar need, PM me and I'll send you a copy of the flow.
Attachments
Shipping Email.jpg
Shipping Email.jpg (45.36 KiB) Viewed 7063 times
laurentd
Member
Posts: 142
Joined: Wed Mar 13, 2019 2:06 pm

Re: Creating a list from multiple xml files

Post by laurentd »

Use XML Pickup, then add a row to a Google Sheet, using the Google Sheets Connect app, for each XML file.
Add at least these columns: internal_order_id and tracking_number

Use assemble job to assemble all your XML files into one job
• Scheme: custom
• Job Identifier: internal_order_id (dataset path)
• Number of files: 99999 (something too big)
• Orphan timeout: 15 (or whatever you want)

Then send that job folder to the Google Sheets Connect app and do a lookup values
• Save found line(s) as private data: all with separator
• Selection: use filter
• Condition 1 column name: internal_order_id
• Operator: equal to
• Value: dataset path to internal_order_id

All the tracking numbers will be saved into the private data GSC.tracking_number
Use it in an email or anything you like.

In order to configure Google Sheets Connect, read page 2 of the documentation and follow the movie.
Don’t forget to share your spreadsheet with the client email.

Your flow will be much smaller and simpler! (10 elements including folders)
On top of it, all the job info will be saved into a Google sheet, also available online and from a smartphone or tablet.
You can also share that sheet with your customer.
Sure you can do something with that, and extend the many possibilities to other projects.
Laurent De Wilde, Solution Architect @ Enfocus
wkopp
Newbie
Posts: 13
Joined: Mon Sep 16, 2019 8:20 pm

Re: Creating a list from multiple xml files

Post by wkopp »

laurentd wrote: Wed May 03, 2023 9:19 am Your flow will be much smaller and simpler! (10 elements including folders)
On top of it, all the job info will be saved into a Google sheet, also available online and from a smartphone or tablet.
You can also share that sheet with your customer.
Sure you can do something with that, and extend the many possibilities to other projects.
Thanks for the tips Laurent! I'll check it out.
Post Reply