Using Infoplus Scripts, you can inject custom JavaScript code into all Infoplus Warehouse Operations Apps (such as Pack Station, Ship Station, Receiving, etc), to help deal with unique needs around barcode scanning, or other adjustments to inputs in our apps.

Due to the ever-changing nature of writing and maintaining scripts, Infoplus does not provide support in this area. We recommend someone in your IT Department handles scripting requests internally so that you keep all control over the process.


To use this feature, you define a script in Infoplus of a Script Type called "Warehouse Apps Input ". Note: you can only have 1-such script in your site. An example is shown below.




The script gets ran in the Infoplus Warehouse Ops apps any time a value is entered into the application.  The script can manipulate the value that the user typed or scanned before it is sent to the Infoplus backend (for example, to remove digits from a barcode).  When the script runs, there are 3 variables available in the runtime context:

  • input - the string that they user scanned or keyed in
  • context - an object containing 2 keys: app and screen, to indicate where the user is currently running.
  • console - the javascript console object (which can be used for logging).





You can see debugging output from the script by opening Chrome Developer Tools, clicking on the Console tab, and observing lines prefixed by Input Customizer. You can use these lines to see what possible values the context.app & context.screen variables will take.


Note that when you make changes to the script (ie, edit its code), you have to reload your (beta) warehouse app to reload the script to have your new changes take effect.  


Making HTTP / API Calls

When this type of script runs, it is executed in the javascript runtime of your browser or mobile device.  This means that to make an HTTP call (such as, to access the Infoplus API), it can use the browser's XMLHttpRequest object.  Note that if you do this, you'll likely want to issue the request in synchronous mode, so that the request will be returned before the app continues to its next step.  


In addition, if the call you make returns JSON, you can translate this into an object using the browser's JSON object. 


Here is an example of a script making an API call, to translate UPC codes on item records to SKU's:


var GLOBAL_RESPONSE;

function requestListener () {
    console.log("Response text: " + this.responseText);
    var responseObject = JSON.parse(this.responseText);
    console.log("Response object: " + responseObject);
    if(responseObject && responseObject.length > 0 && responseObject[0].sku)
    {
        GLOBAL_RESPONSE = responseObject[0].sku;
        console.log("Returning sku: " + GLOBAL_RESPONSE);
    }
}

var isRelocation = (context.app == 'inventory-relocation' && (context.screen == 'scan-start-input' || context.screen == 'scan-start-input-error'));

if(isRelocation)
{
    console.log("Searching API for UPC=" + input);

    var request = new XMLHttpRequest();
    request.addEventListener("load", requestListener);
    request.open("GET", "https://my-infoplus-subdomain.infopluswms.com/infoplus-wms/api/beta/item/search?filter=upc+eq+'" + input + "'", false);
    request.setRequestHeader("API-Key", "my-api-key");
    request.setRequestHeader("Content-Type", "application/json");
    request.send();
    
    return(GLOBAL_RESPONSE);
}


Important notes:  

  • You must insert your own infoplus site's subdomain and an active API key into this script on the request.open and request.setRequestHeader lines.  
  • The requestListener function sets a global variable (GLOBAL_RESPONSE), which is then returned after the completion of the XMLHttpRequest send call.