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

Extract from JSON where it meets certain criteria

I've created a simple flow that when an Item is Created in Sharepoint, it obtains the Tracking Number, posts it to an API through HTTP Post and then upon Success the HTTP Get action occurs and Parse JSON is my next step to get the results of the status of a package.  

 

The output of the Parse Json is:

 

{
"meta": {
"code": 200,
"type": "Success",
"message": "Success"
},
"data": {
"id": "cad7aa9581d4419c69af07dea2296f29",
"tracking_number": "776287275954",
"carrier_code": "fedex",
"status": "delivered",
"track_update": false,
"created_at": "2019-11-05T15:45:00+00:00",
"updated_at": "2019-11-05T15:45:01+00:00",
"order_create_time": null,
"customer_email": "",
"title": "",
"order_id": null,
"comment": null,
"customer_name": null,
"archived": false,
"original_country": "United States",
"singed_by": "BWAKEMAN",
"destination_country": "United States",
"itemTimeLength": 6,
"stayTimeLength": 42,
"origin_info": {
"ReferenceNumber": null,
"ItemReceived": "2019-09-19 16:17:00",
"ItemDispatched": null,
"DepartfromAirport": null,
"ArrivalfromAbroad": null,
"CustomsClearance": null,
"DestinationArrived": null,
"weblink": "http://www.fedex.com/",
"phone": "1 800 247 4747",
"carrier_code": "fedex",
"trackinfo": [
{
"Date": "2019-09-25 09:40:01",
"StatusDescription": "Delivered ",
"Details": "Earth City,MO",
"checkpoint_status": "delivered"
},
{
"Date": "2019-09-25 04:42:00",
"StatusDescription": "On FedEx vehicle for delivery ",
"Details": "SAINT LOUIS,MO",
"checkpoint_status": "pickup"
},
{
"Date": "2019-09-25 04:38:00",
"StatusDescription": "At local FedEx facility ",
"Details": "SAINT LOUIS,MO",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-25 00:18:05",
"StatusDescription": "In transit ",
"Details": "OVERLAND,MO",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-24 12:06:05",
"StatusDescription": "In transit ",
"Details": "CHANDLER,OK",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-23 23:02:04",
"StatusDescription": "In transit ",
"Details": "GRANTS,NM",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-23 09:47:05",
"StatusDescription": "Departed FedEx location ",
"Details": "BLOOMINGTON,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-20 13:21:00",
"StatusDescription": "Arrived at FedEx location ",
"Details": "BLOOMINGTON,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-20 09:01:04",
"StatusDescription": "In transit ",
"Details": "BLOOMINGTON,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-20 09:01:00",
"StatusDescription": "Arrived at FedEx location ",
"Details": "BLOOMINGTON,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-20 04:07:00",
"StatusDescription": "At local FedEx facility ",
"Details": "BLOOMINGTON,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-20 04:00:00",
"StatusDescription": "Arrived at FedEx location ",
"Details": "BLOOMINGTON,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-20 00:10:00",
"StatusDescription": "Left FedEx origin facility ",
"Details": "SAN DIEGO,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-19 19:27:00",
"StatusDescription": "Arrived at FedEx location ",
"Details": "SAN DIEGO,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-09-19 16:17:00",
"StatusDescription": "Picked up ",
"Details": "SAN DIEGO,CA",
"checkpoint_status": "transit",
"ItemNode": "ItemReceived"
},
{
"Date": "2019-09-19 12:17:00",
"StatusDescription": "Shipment information sent to FedEx ",
"Details": "",
"checkpoint_status": "transit"
}
]
},
"service_code": "",
"status_info": "",
"weight": "7.0LB",
"substatus": null,
"packageStatus": "",
"lastEvent": "Delivered ,Earth City,MO,2019-09-25 09:40:01",
"lastUpdateTime": "2019-09-25 09:40:01"
}
}
 
The only information I want is in red within the trackinginfo array where the Status Description  = "Delivered" and then to return the Date of the Delivery to update Sharepoint.  
 
My Flow:
Edit your flow _ Microsoft Flow - Google Chrome 2019-11-06 07.26.49.png

 

Edit your flow _ Microsoft Flow - Google Chrome 2019-11-06 07.27.09 (1).png

 

Edit your flow _ Microsoft Flow - Google Chrome 2019-11-06 07.29.18 (1).png

 

I tried another compose but can't see how to identify the variables. 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

I actually think I figured it was simpler than I assumed.  If I use the first expression to get from my array which is the latest information it works perfectly. 

 

Edit your flow _ Power Automate - Google Chrome 2019-11-06 12.12.29 (1).png

View solution in original post

5 REPLIES 5
Highlighted
Super User II
Super User II

@DynamicsNerd 

Hi there!  Can you post the output of the previous step, please?  Basically, what does the JSON look like before it's parsed.  I may have an idea.

 

Thanks!

-Ed-

 

 

Highlighted

@edgonzales  

 

The previous step before Parse Json 2 in the condition is just the HTTP Get which gets the Tracking Number and Carrier code from the prior steps:

 

Step before Parse Json 2:

Edit your flow _ Microsoft Flow - Google Chrome 2019-11-06 11.23.20 (1).png

 

Output from Previous Run History, hope that's what you meant:

{
"meta": {
"code": 200,
"type": "Success",
"message": "Success"
},
"data": {
"id": "2a620485bf8dcb056571429e325adc79",
"tracking_number": "774532337554",
"carrier_code": "fedex",
"status": "delivered",
"track_update": false,
"created_at": "2019-11-02T19:32:44+00:00",
"updated_at": "2019-11-02T19:32:45+00:00",
"order_create_time": null,
"customer_email": "",
"title": "",
"order_id": null,
"comment": null,
"customer_name": null,
"archived": false,
"original_country": "United States",
"singed_by": "BTUCKER",
"destination_country": "United States",
"itemTimeLength": 6,
"stayTimeLength": 249,
"origin_info": {
"ReferenceNumber": null,
"ItemReceived": "2019-02-21 16:20:00",
"ItemDispatched": null,
"DepartfromAirport": null,
"ArrivalfromAbroad": null,
"CustomsClearance": null,
"DestinationArrived": null,
"weblink": "http://www.fedex.com/",
"phone": "1 800 247 4747",
"carrier_code": "fedex",
"trackinfo": [
{
"Date": "2019-02-27 10:10:03",
"StatusDescription": "Delivered ",
"Details": "Earth City,MO",
"checkpoint_status": "delivered"
},
{
"Date": "2019-02-27 05:16:00",
"StatusDescription": "On FedEx vehicle for delivery ",
"Details": "SAINT LOUIS,MO",
"checkpoint_status": "pickup"
},
{
"Date": "2019-02-27 05:13:00",
"StatusDescription": "At local FedEx facility ",
"Details": "SAINT LOUIS,MO",
"checkpoint_status": "transit"
},
{
"Date": "2019-02-26 12:59:02",
"StatusDescription": "In transit ",
"Details": "SAPULPA,OK",
"checkpoint_status": "transit"
},
{
"Date": "2019-02-25 23:48:04",
"StatusDescription": "In transit ",
"Details": "LAGUNA,NM",
"checkpoint_status": "transit"
},
{
"Date": "2019-02-25 10:12:03",
"StatusDescription": "Departed FedEx location ",
"Details": "BLOOMINGTON,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-02-22 05:32:00",
"StatusDescription": "Arrived at FedEx location ",
"Details": "BLOOMINGTON,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-02-21 21:53:05",
"StatusDescription": "Left FedEx origin facility ",
"Details": "SAN DIEGO,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-02-21 18:54:00",
"StatusDescription": "Arrived at FedEx location ",
"Details": "SAN DIEGO,CA",
"checkpoint_status": "transit"
},
{
"Date": "2019-02-21 16:20:00",
"StatusDescription": "Picked up ",
"Details": "SAN DIEGO,CA",
"checkpoint_status": "transit",
"ItemNode": "ItemReceived"
},
{
"Date": "2019-02-21 16:12:00",
"StatusDescription": "Shipment information sent to FedEx ",
"Details": "",
"checkpoint_status": "transit"
}
]
},
"service_code": "",
"status_info": "",
"weight": "15.0LB",
"substatus": null,
"packageStatus": "",
"lastEvent": "Delivered ,Earth City,MO,2019-02-27 10:10:03",
"lastUpdateTime": "2019-02-27 10:10:03"
}
}

 

The steps prior to that are when item is created in SharePoint and then the following:

Edit your flow _ Microsoft Flow - Google Chrome 2019-11-06 11.25.35.png

 

The outputs from the Parse Json post to the HTTP API call and then the part that I need working is on the GET.  I have recently tried using a condition after Parse Json 2 to Apply to Each and Filter by Array.  It sort of works....I'm not sure if that is an ideal flow action

Edit your flow _ Microsoft Flow - Google Chrome 2019-11-06 11.27.57.png

 

Thank you for your help!

Highlighted

Also if I was just able to get the first Date/status from the trackinginfo array that might work because that's the last "status update" retrieved. 

Highlighted

I actually think I figured it was simpler than I assumed.  If I use the first expression to get from my array which is the latest information it works perfectly. 

 

Edit your flow _ Power Automate - Google Chrome 2019-11-06 12.12.29 (1).png

View solution in original post

Highlighted

Yep.  I was just working on screenshots for that 🙂

 

Great Work!

-Ed-

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (3,791)