Global

priorityReady()

This method is automatically called by the SDK when it has fully loaded. Use it as the entry point for your client side logic. Ensure that ‘priorityReady’ is called first, before you start calling any other SDK methods. This is particularly important if you choose to include the SDK via a script (as opposed to npm). Define this function as a global function:

window.priorityReady = () => {
  //Call some API method here.
}



login(configuration) ⇒ Promise

Use this function to initialize the system and login. A succesful login also returns the LoginFunctions object.

Param Type Description
configuration Configuration Environment configuration object.

Returns: Promise

Resolve: LoginFunctions Object

Reject: ServerResponse

Configuration : Object

Properties

Name Type Description
url string URL to the Priority WCF service. See URL below.
tabulaini string tabula.ini file name.
language number Language code. This determines the language of messages provided by the server, e.g. 3 - American English.
profile object The internal name of the company in Priority to log into.
appname string Application Name - (When developing for Priority, can be accessed in forms and procedures using the variable :WEBSDK_APP_NAME)
username string Username. This is the user’s standard user name in the system, and not the one specially defined for REST API in the Personnel File form in Priority.
password string Password.
devicename string Name of the device (additional information that is logged in the connection log). May be an empty string.
appid string If your application uses a per-application license to connect to Priority (as opposed to generic API license), the unique application ID assigned to your application by Priority Software.
appkey string If your application uses a per-application license to connect to Priority (as opposed to generic API license), the unique application license key assigned to your application by Priority Software.
activeDirectory boolean Optional - use if your organization works with Active Directory. If set to 1, login information in username and password should match the user’s Windows credentials. Supported in version 18.1 and above of Priority.
URL

Local Installations

For local installations, the URL is the url to the Priority WCF service, without the “wcf/wcf/service.svc” part (i.e. the URL configured for the Priority Application Server).

Priority Cloud

For installations hosted on Priority Cloud, a distinction needs to be made between tenants on Private vs. Public Cloud (AWS).

  • On the public cloud (AWS), all installations share the same URL, and are distinguished by differing tabula.ini files. For production environments, the url is:
    https://p.priority-connect.online/wcf/service.svc

    For test environments, the prefix is an s, instead:
    https://s.priority-connect.online/wcf/service.svc

  • On the private cloud, the URL is the url to the Priority WCF service, without the “wcf/wcf/service.svc” part.

Verifying the URL

While Priority Cloud is migrating from the private to the public cloud, given the possible URL variations, you might want to add some code that verifies the URL provided to your app is correct. You can use the Fetch API to check these variations:

async function checkUrlRequest(serverUrl, resolve, reject) {
        let success = false;
        if (serverUrl.toLowerCase().includes('service.svc')) {
            return resolve(serverUrl);
        }
        success = await this.tryFetch(serverUrl + '/wcf/service.svc');
        if (success) {
            return resolve(serverUrl);
        }
        success = await this.tryFetch(serverUrl + '/wcf/wcf/Service.svc');
        if (success) {
            return resolve(serverUrl);
        } 
        return reject({message: 'No WCF service found in URL'});
}       

You can of course extend this code with additional validations, for customers with their own private installations and setups.

profile: Object

Properties

Name Type Description
company string The internal name of a company in Priority. You can find the internal name in the Companies form within Priority.
group? number If the user has multiple user groups (user profiles) in Priority, the id of the desired user group in Priority. Optional

Note: If you are unsure what to enter in url, tabulaini, and profile, check with the Priority system administrator.

Example:

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

async function webSDK() {

let config={
  url:<your url>,
  tabulaini:<your tabula.ini>,
  language: 3,
  profile: {
                company: 'test',
            },
  appname:'demo',
  username:<your username>,
  password: <your password>,
  devicename:'', 
  appid: 'APP001',
  appkey: '15nXqSDXnNeaIEFQSSDXkNeZ16DXodeV16TXmSDXoteb16nXmdeVISEh'
};
try { 
    await priority.login(config)
    console.log('Your are in!! Enjoy!')
}
catch(reason){
    console.error(reason.message)
}
};

Personal Authentication Tokens

Accessing the SDK via Personal Authentication Tokens is available as of version 19.1 of Priority

To use an authentication token to access the SDK, your System Administrator must first generate the token. To access the SDK via the token, specify the following credentials:

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

async function webSDK() {

let config={
  url: <your url>,
  tabulaini: <your tabula.ini>,
  language:3,
  profile: {
                company: 'test',
            }
  appname:'demo',
  username:<your token>,
  password: 'PAT',
  devicename:'', 
  appid: 'APP001',
  appkey: '15nXqSDXnNeaIEFQSSDXkNeZ16DXodeV16TXmSDXoteb16nXmdeVISEh'
};
try { 
    await priority.login(config)
    console.log('Your are in!! Enjoy!')
}
catch(reason){
    console.error(reason.message)
}
};



formStart(formName , onShowMessgeFunc , onUpdateFieldsFunc , profile , autoRetrieveFirstRows) ⇒ Promise

Opens a Form. Call this method once for each Form you want to open.

A Form will stay open until you end it. Once open, you can use all of its methods.

Param Type Description
formName string The internal (uppercase) name of the form, e.g. ‘ORDERS’.
onShowMessgeFunc MessagesCallback Callback function for handling error and warning messages.
onUpdateFieldsFunc UpdateFieldsCallback Callback function for handling form field updates.
profile Profile Object containing the company and user group in which to open the form.
autoRetrieveFirstRows number 1: When opening the form, retrieve records (rows) according to the default query and store them locally. If no default query exists, retrieve top records for form. 2: Retrieve rows according to the user’s default query, if it exists. If no default query exists, open the form but do not retrieve any rows. 0: Open the form, but do not run a query.

Returns: Promise

Resolve: Form

Reject: ServerResponse

FormStartSuccessCallback : function
Param Type Description
form Form Form Object. The name of the form that was started.



MessagesCallback : function

A callback passed to the formStart function. Use it to display messages received from the server.

This callback is called by the SDK whenever messages are received from the server after calling a Form Object method.

Notes:

  • If the server returns an error after calling an API method, it indicates the action has resulted in a Priority error and the promise is rejected. The error message will be returned through messagesCallback, but any catch block will run.
  • When the server returns a warning after calling an API method, it indicates the user has encountered a warning message where they must decide whether to continue the action or cancel it. The warning message will be returned to the messagesCallback and the action will not be completed until:

    • The action is approved despite the warning - warningConfirm is called with ‘okCancel’ = 1. In this case the original promise that triggered the warning is resolved.
    • The action is canceled due to the warning - warningConfirm is called with ‘okCancel’ = 0. In this case the original promise that triggered the warning is rejected.
  • When the server returns an information message after calling an API method, it indicates the user has encountered an informational message regarding the current action (for example, a message related to a customer that was selected). This message simply needs to be confirmed. The message will be returned to the messagesCallback and the action will be completed once the infoMsgConfirm function is called.
Param Type Description
serverResponse ServerResponse Server response that contains a message.


UpdateFieldsCallback : function

A callback function passed to the formStart function. This callback is called by the SDK when updates to a Form’s row or field are received from the server. Updates can be received after performing certain actions, including:

Note: This callback should be carefully implemented to cover all ‘update’ cases, in order to ensure local data is always synchronized with data on the server.

Param Type Description
result Rows Updated rows.

Example:

let customersForm;

const updateFieldsCallback = (updates)=> {
  if(updates["CUSTOMERS"] != null) {
    Object.assign(customersForm.rows,updates["CUSTOMERS"]);
  }
}

const messagesCallback = (serverMessage)=> {
  alert(serverMessage.message);
}

try {
customersForm = await formStart("CUSTOMERS", updateFieldsCallback, messagesCallback)
...
}
catch {
  //reject
}



Profile: Object

Properties

Param Type Description
company string The internal name of the company in which the form is opened.
group? number If the user has multiple user groups (user profiles) in Priority, the id of the desired user group in Priority. Optional



formStartEx(formName , onShowMessgeFunc , onUpdateFieldsFunc , profile , autoRetrieveFirstRows , exParams) ⇒ Promise

Opens a Form in a special mode that can call on additional parameters. Specifically, you can use the exParams object to specify a row number and this function will open the form and retrieve that row (when the getRows method is called).

Note: Other parameters of formStartEx are identical to those of formStart.

exParams : object

Contains additional parameters used by the formStartEx function.

Properties

Name Type Description
zoomValue string A key value identifying a specific row in the form. If a zoomValue has been specified, getRows will retrieve the form row identified by this value.



procStart(name, type, progressCallback, dname) ⇒ Promise

Start a Procedure or a report.

Param Type Description
name string The internal (uppercase) name of the procedure, e.g. ‘WWWSHOWORDER’.
type string Type (R for report, P for procedure).
progressCallback ProcProgressCallback Callback function for displaying progress.
dname string Internal name of the company in which the procedure is run.



ServerResponse : Object

Properties

Name Type Description
form Form The name of the form object on which the rejected action was performed.
message string The error or warning message received from the server.
fatal boolean Indicates whether the error fatal. When True, this means that the form was closed by the server, and you cannot continue working with it. The form will have to be reopened. If this repeats, consult with the systems administrator for this Priority installation.
type string Gives more information about the message type. This can be one of ServerResponseType.
code string Gives more information about the message type. This can be one of ServerResponseCode.



ServerResponseType : enum

Properties

Name Type Value Description
Error string "error" Indicates there was a error message from Priority.
Warning string "warning" Indicates there was a warning message from Priority. Warning messages allow the user to decide whether to continue the current action or cancel it.
information string "information" Indicates there was an informational message from Priority.
APIError string "apiError" Indicates there was a fatal error somewhere. Could be a syntax error, API error, exception, etc.



ServerResponseCode : enum

Properties

Name Type Value Description
NoHtml string "noHtml" There was an attempt to add text in form which is not a freeform text form.
ReadOnlyForm string "readOnlyForm" There was an attempt to save text in a read-only form.
TextTooLong string "textTooLong" There was an attempt to save text that is too long.
MustSaveOrDiscard string "mustSaveOrDiscard" There was an attempt to move to a different row before saving/discarding the changes in the current row.
Exception string "exception" There was an API exception.
NoClearOnSubForm string "noClearOnSubForm" There was an attempt to call the method ‘clearRows’ on a subform.
FileIsNull string "fileIsNull" There was an attempt to upload an empty file through the upload function.
NoSuchSubForm string "noSuchSubForm" There was an attempt to perform an action on a subform that does not exist.
NoSuchColumn string "noSuchColumn" There was an attempt to perform an action on a column that does not exist.
FailedPreviousRequest string "failedPreviousRequest" The previous API request was deleted from the request queue, meaning it was rejected.
WarningCancel string "warningCancel" The user canceled their action based on a warning message received from Priority.
LoginFailed string "loginFailed" Login failed.
InvalidFilter string "invalidFilter" The filter used for row retrieval is incorrect.
ReadWrite string "readWrite" When updating text forms - the form is locked as the text is already being edited by someone else.
Stop string "stop" The current API request was stopped.
NotSupport string "notSupportedInThisPriorityVersion" The function called is not supported by the Priority version installed on the server.
LoginExpired string "loginExpired" The user logged in with a password that has expired.