Fulfillment
Scheduled - Twice Daily
Starting Time: 8:10am
Flow: NS Shipments to Shopify Fulfillments
Sources
Netsuite Export
Utilizing the Celigo Fulfillments Saved Search, we pull out each individual line item as it is fulfilled.
https://1019389.app.netsuite.com/app/common/search/search.nl?id=9044&whence=
Filter - Quantity > 0 and last 30 days.
info
Why So Far Back? When sending a lot of data to Shopify Celigo throws errors, this method makes 100% certain ALL items are matched and show shipped.
Destinations & Lookups
Get Shopify Orders
Simple lookup from shopify orders API to get the fulfillment info to fulfill the order. We map the data response to a new array called DATA.
Import Shopify Fulfillments
API Name: Shipping and fulfillment : Fulfillment
Operation: Create new fulfillment
Order Id: {{[Shopify ID]}}

Location ID - https://shop-gemlux.myshopify.com/admin/settings/locations, click on the location you have inventory and the id is in the url.
PreSave Hook - processes out the line ids needed to fulfill the object based on the SKU.
function preSavePageFunction(options, callback) {
return(options.data.map((d) => {
d.fulfillID = 0;
for(var i = 0; i <d.data[0].line_items.length; ++i) {
if(d.data[0].line_items[i].sku === d.Item) {
d.fulfillID = d.data[0].line_items[i].id;
d.recordType = d.data[0].line_items[i].id;
}
}
if(d.fulfillID == 0 && d.Item.includes(':')) {
var newSKU = d.Item.split(':')[d.Item.split(':').length - 1].trim();
for(var i = 0; i <d.data[0].line_items.length; ++i) {
if(d.data[0].line_items[i].sku === d.Item || d.data[0].line_items[i].sku === newSKU) {
d.fulfillID = d.data[0].line_items[i].id;
d.recordType = d.data[0].line_items[i].id;
}
}
}
return { data: d }
})
)
}
Post Save Hook - if the session fails, we ignore errors of already fulfilled and you are fulfilling too many, as these alerts are not worrisome since we are not doing a delta sync and the next run it will fulfill the items (or in the already fulfilled case - it has been fulfilled).
function postSubmit (options) {
//console.log(options.responseData.errors.length)
for(var dT = 0; dT < options.responseData.length; ++dT) {
for(var i = 0; i < options.responseData[dT].errors.length; ++i) {
if(options.responseData[dT].errors[i].message.includes("already fulfilled")) {
options.responseData[dT].ignored = true;
}
if(options.responseData[dT].errors[i].message.includes("must be less than or equal to the fulfillable line item")) {
options.responseData[dT].ignored = true;
}
}
}
return options.responseData
}