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=function()
{
  //Call some API method here.
}



login(configuration , successCallback , errorCallback)

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.
successCallback LoginSuccessCallback Called on success.
errorCallback ErrorCallback Called on error.

Returns: Promise - - When both onSuccess and onError are not provided.

Fulfill: LoginFunctions Object

Reject: ServerResponse

Configuration : Object

Properties

Name Type Description
url string URL to the Priority WCF service without the “wcf/wcf/service.svc” part (i.e. the URL configured for the Priority Application Server).
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.
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.
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.

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

Example:

var config={
  url:<your url>,
  tabulaini:<your tabula.ini>,
  language:3,
  profile: {
                company: 'test',
            }
  appname:'demo',
  username:<your username>,
  password: <your password>,
  devicename:'', 
  X-App-Id: 'APP001',
  X-App-Key: '15nXqSDXnNeaIEFQSSDXkNeZ16DXodeV16TXmSDXoteb16nXmdeVISEh'
};
login(config).then(
  onsuccess=>
  {
    console.log('Your are in!! Enjoy!');
  },
  reason=>
  {
    console.log(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:

var config={
  url:<your url>,
  tabulaini:<your tabula.ini>,
  language:3,
  profile: {
                company: 'test',
            }
  appname:'demo',
  username:<your token>,
  password: 'PAT',
  devicename:'', 
  X-App-Id: 'APP001',
  X-App-Key: '15nXqSDXnNeaIEFQSSDXkNeZ16DXodeV16TXmSDXoteb16nXmdeVISEh'
};
login(config).then(
  onsuccess=>
  {
    console.log('Your are in!! Enjoy!');
  },
  reason=>
  {
    console.log(reason.message);
  }
);



loginSuccessCallback : function

Called upon a successful login.

Param Type Description
LoginFunctions LoginFunctions LoginFunctions object, that has various methods for retrieving information about the Priority installation and API .



formStart(formName , onShowMessgeFunc , onUpdateFieldsFunc , profile , autoRetrieveFirstRows , [onSuccess] , [onError]) ⇒ 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.
[onSuccess] FormStartSuccessCallback Called on success.
[onError] ErrorCallback Called on error.

Returns: Promise - - When both onSuccess and onError are not provided.

Fulfill: 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:

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:

var customersForm;

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

function messagesCallback(serverMessage) {
  alert(serverMessage.message);
}

formStart("CUSTOMERS", updateFieldsCallback, messagesCallback).then(function(form) {
      customersForm = form;
    },function() {
      //reject
    });



Profile: Object

Properties

Param Type Description
company string The internal name of the company in which the form is opened.
group string The name of the usage-profile with which the form is opened. Can be left empty.



SuccessCallback : function

Param Type Description
result Empty object The result of the operation. This can be ignored.



ErrorCallback : function

Param Type Description
serverResponse ServerResponse Response from Priority with error message or warning message text.



formStartEx(formName , onShowMessgeFunc , onUpdateFieldsFunc , profile , autoRetrieveFirstRows , exParams , [onSuccess] , [onError]) ⇒ 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, successCallback, errorCallback)

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.
successCallback ProcSuccessCallback Called on success.
errorCallback ProcErrorCallback Called on error.



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.