The following examples are implemented using NodeJS, and use async/await to perform asynchronous functions.

Working with Actions

In this first example, we will retrieve a part in Priority using a filter, and then we will change the unit of measurement for this part, using an Action.

After logging in, we open the relevant form, in this case the LOGPART (Part Catalogue) form.

//Open the LOGPART Form

const mainFormHandler = await priorityWebSdk.formStart('LOGPART', onShowMessge, null, company, 0);

// Create a filter to locate the desired part by part number, in this example - "001"

let filter = {
or: 0,
ignore case:1,
QueryValues: [{
    field : "PARTNAME",
    fromval : "001",
    op : "=",
    sort : 0,
    isdesc : 0

//Set the new filter on the form

await mainFormHandler.setSearchFilter(filter);

//retrieve form rows with the applied filter

await mainFormHandler.getRows(1);
await mainFormHandler.setActiveRow(1)

Now that we have the part we want, we’ll activate the CHUNIT action to change the unit of measurement for this part. CHUNIT is a procedure.

Tip: Procedures run in stages. In each stage you can output the result to the log, which lets you see the next stage of the procedure and what you should do.

  1. The first stage will be to activate the procedure:
    Let result = await mainFormHandler.activateStart('CHUNIT', 'P');
  2. Now we’ll print the result Object to the log and see the following: ```js result: { proc: { title: ‘Change Part Unit’, name: ‘CHUNIT’, message: [Function], reportOptions: [Function], documentOptions: [Function], inputFields: [Function], inputOptions: [Function], inputHelp: [Function], continueProc: [Function], cancel: [Function], choose: [Function], searchAction: [Function], uploadFile: [Function], uploadDataUrl: [Function], cancelFileUpload: [Function], isSupported: [Function] }, type: ‘inputOptions’, input: { Options: [ [Object], [Object], [Object] ] }, text: ‘Run this program to assign a different unit (factory, buy/sell or both) to the specified part once inventory transactions have been reported for it. Also use it to simultaneously change both units of multiple parts. This will change the unit(s) for all inventory transactions and warehouse balances involving this part - past, present and future. It will not, however, affect quantities. \n\n Notes\n- When revising a single unit only (either factory or buy/sell unit), the conversion ratio between the original unit and the new unit must equal 1. \n
    • When revising both factory and buy/sell units, the conversion ratio between them must be identical to that between the original pair of units.\n
    • If any errors were encountered when running the program, you will be referred to the “Change Part Unit - Errors” report. \n
    • Use of this program is limited to the system manager.’, title: ‘Unit to Change’ } } ```

We can see in result.type that the current stage requires that we provide input for the procedure,

In this case, we need provide input using an “inputOptions” Object.

  1. By printing the variable result.input.Option to the log, we can see our options:
[ {

field: 1,

helpstring:'Select this option to change the factory unit of the specified part.',

name: 'CH1',selected: 1, title: 'Factory Unit'



field: 2,

helpstring:'Select this option to change the buy/sell unit of the specified part.',

name: 'CH2',selected: 0,title: 'Buy/Sell Unit' },


field: 3,

helpstring:'Select this option to change both the factory unit and the buy/sell unit of the specified part(s).\\n\\n Note: The same unit will be assigned for both factory and buy/sell unit.',
name: 'CH3', selected: 0, title: 'Both Units'
} ]
  1. Basically, in this input stage we can choose one of 3 options. To input our response, we’ll use the following code:
    result = await result.proc.inputOptions(1, 1);

In this case, we input our selection of option 1 to the procedure, that is, we intend to change the “Factory Unit”.

  1. We now get to the next stage in the procedure: inputFields. In our case we only have one input parameter, that being the new unit that we want to set. We will define a new Object called “Input”, with the following structure:
Input = {



    value: 'lb'


  1. The next step is to send it to Priority procedure:

await result.proc.inputFields(1, Input)

  1. The final result will be:
    { proc:
    { title: 'Change Part Unit',
    name: 'CHUNIT',
    message: [Function],
    reportOptions: [Function],
    documentOptions: [Function],
    inputFields: [Function],
    inputOptions: [Function],
    inputHelp: [Function],
    continueProc: [Function],
    cancel: [Function],
    choose: [Function],
    searchAction: [Function],
    uploadFile: [Function],
    uploadDataUrl: [Function],
    cancelFileUpload: [Function],
    isSupported: [Function] },
    type: 'end' }
  2. Since the type is end, this we reached the end of the procedure.

Uploading a File

An example of uploading an attachment via Priority WebSDK by using dataURI.

To start, we’ll open the Sales Orders form (ORDERS), and retrieve the order we want to attach our file to, using a filter.

//Open ORDERS form

const mainFormHandler = await priorityWebSdk.formStart('ORDERS',

onShowMessge, null, company, 0);

//set a filter and search for ORDNAME - SO19001473

let filter = {
or: 0,
QueryValues: [{
field : " ORDNAME",
fromval : " SO19001473",
op : "=",
sort : 0,
isdesc : 0

//set a new filter

await mainFormHandler.setSearchFilter(filter);

//get the specific row by this filter

await mainFormHandler.getRows(1);

Next, we’ll open the Attachments sub-level form:

//start sub form – attachments form

let subform = await mainFormHandler.startSubForm('EXTFILES', onShowMessge,null);

You can read more about DATA URIs here.

First, we configure our file:

let dataURI = data:\${contentType};base64,\${base64Content}

let fileType = ”pdf; //String 

let fileName = “file name;//String

Then we upload the file to the Priority server.

let uploadResult = await subform.uploadDataUri(dataURI, fileType, function (fileUploadResult) {

if (fileUploadResult.isLast) {


    }else {

       console.log("File upload progress" + fileUploadResult.progress);



Once the upload is done, we can save it as a new row in the Attachments (EXTFILES) sub-level form.

await mainFormHandler.newRow();

await mainFormHandler.fieldUpdate("EXTFILENAME", uploadResult.file);

await mainFormHandler.fieldUpdate("EXTFILEDES", fileName);

await mainFormHandler.saveRow(0);