Skip to main content

I’m building a custom integration for myself. I’m making an API call to return some shipments with tracking info. That’s all working fine. However, I want the user to be able to set a value for inputData.store_code and then the results be filtered based on their set value. For example, the unfiltered results would look like this:

 

{
"sales_order_number": "SO-860444",
"merchant_order_number": "186C-1088",
"tracking_number": "666000987",
"amount": "0.00",
"shipped_via": "FedEx Home Delivery",
"shipped_on": "2022-07-15T19:32:17Z"
},
{
"sales_order_number": "SO-1042038",
"merchant_order_number": "226C-1025",
"tracking_number": "666000123",
"amount": "0.00",
"shipped_via": "FedEx Ground",
"shipped_on": "2022-07-15T19:27:21Z"
}

 

I’d want the user to set their store code to something like “186C” and then for the orders to be filtered based on that string appearing in the merchant_order_number.

What’s the best way to go about this? Was hoping to find a similar issue here in the community, but maybe I’m looking for the wrong thing.

After you get all the data into an array (let’s call it `data`), you could filter it with something like

 

`const filtered_data = data.filter(object => object.merchant_order_number.includes(bundle.inputData.store_code))`

 

Do you want to give that a shot and let us know how it goes?


This is brilliant and far simpler than I was expecting! I was able to get it to work with this. Thank you :-)