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

Running a Report

To start with, log in to Priority; set the configuration object based on your own environment.

"use strict";

const priority = require('priority-web-sdk');

const conf = {
  username: 'me', password: 'xxxx',
  url: 'https://www.eshbelsaas.com',
  tabulaini: 'tabula.ini',
  language: 3,
  company: 'ui'
};

(async () => {
  try {
       
    await priority.login(conf);

Start the report. In this example, we’ll use ABC for Raw Materials.

    let procStepResult = await priority.procStart('ABCRAW', 'P');

The server responds with step type inputOptions. This means we need to select an option and press ok. We can see the available options by accessing input.options.

    procStepResult = await procStepResult.proc.inputOptions(1 , 1);

The server responds with the next step type inputFields, which means we need to provide data in specific fields. We can check the required fields by accessing input.EditFields. In this case, we need to provide a start and end date, both in format Date8.

    var data = {EditFields: [
      {field: 1, op: 0, value: '01/08/20'},
      {field: 2, op: 0, value: '31/08/20'}
    ]};
    procStepResult = await procStepResult.proc.inputFields(1 , data);

The next step is once again inputFields. This time we need to provide a single field.

    data = {EditFields: [
      {field: 1, op: 0, value: '*'}
    ]}; 
    procStepResult = await procStepResult.proc.inputFields(1 , data);

The next step type received is displayUrl. This means the report was prepared by the server and can be accessed. The report is available in the Urls property.

Based on server configuration, this might be a url to the report which can be downloaded seperately, or a DataURI which contains the report data.

    console.log(procStepResult.Urls);

    await procStepResult.proc.continueProc();  // Finish the proc execution context
  } catch(err) {
    console.log('Something bad happened:');
    console.dir(err);
  }
})();