Turn any value stored in Infoplus into a scannable input to streamline your pick, pack, and ship process.
If the script does not return anything, the user-entered value will be sent to Infoplus.
Use Case:
Example Warehouse Apps Input Script:
// A script of this type has the following variables available:
//
// input - string - value scanned or keyed into the app by the user
// context - object - 2 keys: app and screen - indicate what app & screen the user is on when the input value was read.
// console - object - the javascript console object - can be used to issue log message, e.g., console.log('trimming value')
//
// If this script returns a value, it will be sent to Infoplus instead of the value that the user entered.
// If the script does not return anything, the user-entered value will be sent to Infoplus.
//
// Example:
console.log('input customizer');
The section below is declaring global variables and setting a function for an event listener (the scanner).
var GLOBAL_RESPONSE;
var GLOBAL_ORDER;
function requestListener () {
console.log("Response text: " + this.responseText);
var responseObject = JSON.parse(this.responseText);
console.log("Response object: " + responseObject);
if(responseObject && responseObject.length > 0)
{
GLOBAL_RESPONSE = responseObject[0].sku;
GLOBAL_ORDER = responseObject[0].orderNo;
console.log("Returning sku: " + GLOBAL_RESPONSE);
console.log("Returning order: " + GLOBAL_ORDER);
}
}
Next, there is a function created for whatever search is going to be needed, in the example below there is a function for an item search, and I included one that searches the order table just for reference. It's important that our customers put in their site URL and an accurate API key from their user table.
function orderSearch(field, value)
{
var request = new XMLHttpRequest();
request.addEventListener("load", requestListener);
request.open("GET", "https://CUSTOMER-SITE.infopluswms.com/infoplus-wms/api/beta/order/search?filter=" + field + "+eq+'" + value + "'", false);
request.setRequestHeader("API-Key", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
request.setRequestHeader("Content-Type", "application/json");
request.send();
return(GLOBAL_ORDER);
}
function itemSearch(field, value)
{
var request = new XMLHttpRequest();
request.addEventListener("load", requestListener);
request.open("GET", "https://CUSTOMER-SITE.infopluswms.com/infoplus-wms/api/beta/item/search?filter=" + field + "+eq+'" + value + "'", false);
request.setRequestHeader("API-Key", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
request.setRequestHeader("Content-Type", "application/json");
request.send();
return(GLOBAL_RESPONSE);
}
Now we can set the variables for each mobile application context screen. You can find the context of any screen you are in by using the console log of Inspector Element.
- var isItemInquiry = (context.app == 'item-inquiry');
- var isReceiving = (context.app == 'interactive-receiving' && (context.screen == 'scan-identifier' || context.screen == 'select-asn-line'));
- var isFulfillmentPick = (context.app == 'perform-fulfillment-pick-work' && (context.screen == 'error-scan-item' || context.screen == 'scan-item'));
- var isPackStation = (context.app === 'pack-station');
- var isPackStationItem = (context.app == 'pack-station' && context.screen == 'scan-item');
- var isPackStationOrder = (context.app == 'pack-station' && context.screen == 'scan-order');
- var isRelocation = (context.app == 'inventory-relocation' && (context.screen == 'scan-start-input' || context.screen == 'scan-start-input-error'));
- var isAdjustment = (context.app == 'adjust-inventory' && (context.screen == 'scan-start-input' || context.screen == 'scan-start-input-error'));
- var isInventoryStatus = (context.app == 'change-inventory-status' && (context.screen == 'scan-start-input' || context.screen == 'scan-start-input-error'));
We have an if statement set to determine if any of the context screens from above are currently in use. If so, we call the functions that were set earlier and return the global response (item / sku, in this example)
if(isRelocation || isAdjustment || isInventoryStatus || isItemInquiry || isReceiving)
{
console.log("Searching API for UPC= " + input);
var sku = itemSearch("vendorSKU", input);
if(sku)
{
return(sku);
}
var sku = itemSearch("upc", input);
if(sku)
{
utils.log("UPC Search Ran");
return(sku);
}
var sku = itemSearch("custom.upc2", input);
if(sku)
{
utils.log("UPC2 Search Ran");
return(sku);
}
sku = itemSearch("custom.upc3", input);
if(sku)
{
utils.log("UPC3 Search Ran");
return(sku);
}
sku = itemSearch("custom.upc4", input);
if(sku)
{
utils.log("UPC4 Search Ran");
return(sku);
}
sku = itemSearch("custom.pickUPC", input);
if(sku)
{
utils.log("pickUPC Search Ran");
return(sku);
}
}
// if (isPackStation || isPackStationOrder || isOrderInquiry)
// {
// console.log("Searching Order API for Order with Fulfillment Process " + input);
//
// var order = orderSearch("fulfillmentProcessId", input);
// if(order)
// {
// console.log("Returning Order " + order + ".");
// return(order);
// }
//
// }