Form: object type

Properties

Name Type Description
name string The form’s uniqe uppercase ‘Priority’ name.
columns Object An object containing all of a form’s columns. Key: the column’s name, Value: a Column.
ishtml number Indicates whether the form is a html text form. 0 or 1.
ishtmleditable number If the form is a text form, indicates if the form can be edited (based on the user’s permissions). 0 or 1.
isquery number Indicates whether the form is a query form i.e. read-only. 0 or 1.
oneline number Indicates whether the form can only contain a single row. 0 or 1.
subForms Object A list of the form’s subforms. Key: the subform’s name, Value: a Subform
windowSize number The maximum number of rows to be retrieved by the default query or when using getRows.
title string The form’s title.



warningConfirm(okCancel)

Confirms a server warning message. Every operation can trigger a warning messages on the server.

This method is used to make the server aware of the last operation’s state:

  • If the the user approves the action despite the warning message, specify 1 in the ‘okCancel’ parameter. When the server completes the operation, it will resolve the promise in the last server call.
  • If the the user cancels the action following the warning message, specify 0 in the ‘okCancel’ parameter. When the server completes the operation it will reject the promise in the last server call.
Param Type Description
okCancel boolean 1: ok, 0: cancel

Returns: Void



infoMsgConfirm()

Confirms a server information message. Every operation can trigger informational messages from the server. Call this method when the user confirms they have read the message.

Returns: Void

isAlive() ⇒ Promise

Checks whether a form is alive on the server. Attempting to call methods for a dead form will cause errors.

Returns: Promise-

Fulfill: number- 1: alive, 0: not alive.

Reject: ServerResponse

startSubForm(formName, onShowMessgeFunc, onUpdateFieldsFunc) ⇒ Promise

Starts a Sub-Form and sets the active row to be the first row of the Sub-Form.

See setActiveRow.

Param Type Description
formName string for example: ORDERITEMS.
onShowMessgeFunc object Callback function for handling error and warning messages (if null, uses the parent form callback).
onUpdateFieldsFunc object Callback function for handling field updates (if null, uses the parent form callback).

Returns: Promise-

Fulfill: Form

Reject: ServerResponse



endCurrentForm(returnJustThisRow) ⇒ Promise

Exits the current form. If the form is a Subform, returns to the active row originally set in the parent form. See setActiveRow.

Param Type Description
returnJustThisRow boolean Optional; available in Priority 21.0. When the form is accessed from a procedure, determines the values returned to the procedure. If true, returns the relevant value from the currently active row, otherwise returns values from all rows retrieved by the current filter.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



setSearchFilter(filter) ⇒ Promise

Sets a search filter in a form or sub-level form. The filter is used to retrieve rows according to a certain query. See getRows. In order to clear the filter call clearSearchFilter.

Note: As long as you do not clear or change the filter, it will remain in effect. Every call to getRows will return rows according to that filter.

Param Type Description
filter Filter A filter object.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



clearSearchFilter() ⇒ Promise

Clears the search filter. After clearing the filter, the getRows method will use the default query for the form when retrieving rows.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



getRows(fromRow) ⇒ Promise

Returns rows data for the current form. The number of rows retrieved is limited by the windowSize property of the Form object.

Notes:

  • If the current form was started with the parameter autoRetrieveFirstRows=1 or 2, the first time you call this function the API will not go to the server but instead return rows that were already retrieved and stored locally.
  • If a default query has been defined for the form, or a Filter is set, the returned rows will be according to the query or the filter.
Param Type Description
fromRow number The position of the first row to be retrieved.

Returns: Promise

Fulfill: Rows

Reject: ServerResponse


Rows : Object

{   
  "FORM_NAME" :   
          {      
            "row_index" :       
            {          
                "FIELD_NAME" : value,          
                "ANOTHER_FIELD_NAME" : value
                ...        
            },       
            "another_row_index": 
            {
              ...
            }
          } 
} 



clearRows() ⇒ Promise

Clears all rows of a parent form. This does not delete rows, but rather makes them inaccessible until retrieved again.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



newRow() ⇒ Promise

Creates a new row in the current form, then sets it as the active row.

Returns: Promise

Fulfill: RowIndex

Reject: ServerResponse

setActiveRow(row) ⇒ Promise

Sets the active row to the specified row. Note that the row number index starts at 1.

Note: To perform actions on a row, you must first set it as the active row.

Param Type Description
row number Row index number.

Returns: Promise

Fulfill: RowIndex

Reject: ServerResponse



fieldUpdate(fieldName ,fieldValue) ⇒ Promise

Changes or adds a value in a field in the currently active row. The updated information is returned through UpdateFieldsCallback. After changing the value in the field, Priority triggers may be executed, updating additional fields. These changes are also returned via UpdateFieldsCallback Calling this action does not save the new value.

Param Type Description
fieldName string Name of the field. All uppercase.
fieldValue string The new value of the field.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



saveRow(backToParentForm) ⇒ Promise

Saves all changes made to the currently active row. Updated data is returned via UpdateFieldsCallback.

Param Type Description
backToParentForm number 0: Stay in the current row after saving 1: Applicable only when saving a row in a Sub-Form. Go back to parent form, and set the parent row as the active row.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



saveText(text, addFlag, signatureFlag, secondaryLanguageFlag) ⇒ Promise

Adds new text to a html text form.

Param Type Description
text string The new text to add. May be formatted as plain text or html).
addFlag boolean Append new text to existing text (1). Replace existing text with new text (0).
signatureFlag boolean Add a user signature (1). Don’t add a signature (0).
secondaryLanguageFlag boolean Determines the language of the signature: using the primary system language (0), or English (1). Useful when the primary language is not English.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



undo() ⇒ Promise

Undoes any unsaved changes in the current row made by fieldUpdate. This includes changes made by Priority triggers. Updated data is returned via UpdateFieldsCallback.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



delRow() ⇒ Promise

Deletes the current row. Updated data is returned via UpdateFieldsCallback.

When a row is deleted, the server returns a collection of rows with updated index numbers.

Each row that was after the deleted row gets an index number prior to what it had before the delete.

Thats way the order of the rows is kept.

In this method the server returns the index of the last row. Used to update the view with the changes.

Returns: Promise

Fulfill: RowIndex

Reject: ServerResponse


choose( fieldName, fieldValue) ⇒ Promise

Opens a choose/search operation for a specified field. A successful Choose function results in either a Choose or Search object that contain either ‘ChooseLine’ values or ‘SearchLine’ values, respectively. Certain choose fields can become search fields when there are enough values to choose from. Therefore, after a successful Choose, make sure your code can address both types of results.

Note: If the field currently contains a value, it will automatically be filled in as fieldValue, even if a different fieldValue was specified.

Param Type Description
fieldName string The field’s name (for example CUSTNAME).
fieldValue string Current value in the field.

Returns: Promise

Fulfill: Search/‘Choose’

Reject: ServerResponse

Example:

      let search = await form.choose('TYPE', 'R')
      //Check whether result is search or choose object
      if (search.SearchLine === undefined){
        console.log(search.ChooseLine)
      } else {
        console.log(search.SearchLine)
      }




filterChooseAction(action, searchText) ⇒ Promise

Certain forms in Priority are subject to Business Process Management (BPM) restrictions. This means that users are restricted in the values they can see when running a ‘choose’ on a Status or Assigned To column. This can be an issue when users want to search for documents according to these values. This function circumvents this limitation and displays all available values. Use it when constructing a filter through user input.

In all other respects, this function is completely identical to choose.



searchAction(action, searchText) ⇒ Promise

Performs one of the following actions on the previously opened search field:

  • Next(1) - Retrieve more search results.
  • Prev(2) - Retrieves the previous search results. Usually, this action is unnecessary, as previously retrieved results are cached locally.
  • TypeChange(3) - Change the ‘search-by’ method. Available methods are: By Name, By Number, By Foreign Name.
  • TextChange(4) - Changes the search query text.
  • StartChange(5) - Specifies that the search should look for results that start with the query text.
  • IgnoreCaseChanged(6) - When running a search in English (or other languages with uppercase and lowercase), toggles the ‘ignoreCase’ flag on or off.
Param Type Description
action number One of the above actions.
searchText string The text to search for.

Returns: Promise

Fulfill: Search

Reject: ServerResponse

filterSearchAction (action, searchText) ⇒ Promise

Certain forms in Priority are subject to Business Process Management (BPM) restrictions. This means that users are restricted in the values they can see when running a ‘searchAction’ on a Status or Assigned To column. This can be an issue when users want to search for documents according to these values. This function circumvents this limitation and displays all available values. Use it when constructing a filter through user input.

In all other respects, this function is completely identical to searchAction.



activateStart(ename, type, progressCallback) ⇒ Promise

Starts an Action. An Action is a Procedure;

Param Type Description
ename string Name of procedure/report.
type string Specify : “R” for reports, “P” for procedures
progressCallback ProcProgressCallback Called in case the ‘activitation’ in question takes some time to complete. Indicates a progress bar should be shown.

Returns: Promise

Fulfill: Object

Reject: Object. See ProcErrorCallback



activateEnd() ⇒ Promise

Call this after an action has finished to refresh the current form’s data.

Returns: Promise

Fulfill: Empty object

Reject: ServerResponse



getFileDataUri(filename) ⇒ Promise

When given a relative path of a file on the server, provides the file in data url format.

Param Type Description
filename string The file’s data url.

Returns: Promise

Fulfill: string - file data url

Reject: ServerResponse



uploadFile(file, [onProgress]) ⇒ Promise

Uploads a file to the server from a Blob or File object. Can be used both in a parent form and in a sub-form in file fields.

Allowed file types are determined by the Uploadable File Types in Priority.

Note: This function only uploads the file to the server. Use fieldUpdate to attach it to an attachment field in a particular row.

Param Type Description
file Object A File Object (This object can be obtained from a <input type="file"> HTML tag in the view).
onProgress UploadFileProgressCallback If a file is large and uploaded in chunks, called periodically to update progress.

Returns: Promise

Fulfill: FileResult

Reject: ServerResponse



uploadDataUri(dataURI, type, onProgress) ⇒ Promise

Uploads a file to the server in dataURL format. Can be used both in a parent form and in a sub-form in files fields. Any file type in base64 format is supported, although some file types may be blocked by Priority.

Note: This function only uploads the file to the server. Use fieldUpdate to attach it to an attachment field in a particular row.

Param Type Description
dataURI string The file data you want to upload in a dataURI format.
type string The file type (e.g., .png, .pdf).
onProgress UploadFileProgressCallback If a file is large and uploaded in chunks, called periodically to update progress.

Returns: Promise

Fulfill: FileUploadResult

Reject: ServerResponse



cancelFileUpload()

Cancels the current upload action. Once cancelled, the UploadFile promise is resolved immediately.



UploadFileProgressCallback : function

Param Type Description
result FileProgress Upload progress object.



Column : Object

Properties

Name Type Description
attachment number Indicates whether files can be attached in this field. 0 or 1.
decimal number For decimal fields, the decimal precision.
format string In date fields, the field’s format, e.g. ‘DD/MM/YY’. Date and time data must match the ISO 8601 datetime format and include the timezone offset (e.g. 2018-08-14T10:00:00.000+03:00).
mandatory number Indicates whether the field is mandatory. 0 or 1.
maxLength number Maximum number of characters in the field. Used for text and number fields.
readonly number Indicates whether the field is read-only. 0 or 1.
title string Field’s title that should be displayed to the user.
type string Field’s type, one of: [text,number,date,boolean etc.]
zoom string A field’s special property. Can be Search (a searchlist can be opened), Choose (a chooselist can be opened), Attach (a file can be attached. Equivalent to ‘attachment’=1) or None.



Subform : Object

Properties

Name Type Description
title string the subform’s title.



Filter : Object

Properties

Name Type Description
or number Define the operator between ALL query values. 0: AND, 1: OR.
ignorecase number 0: case sensitive, 1: case insensitive.
QueryValues QueryValue[] Array of query values to filter. Each query value defines the field to filter, relational operator, values and sort options. When using OR operator, you should limit your query to 4 fields.

Notes

  • You can only query a field once per filter.
  • Search is performed from the beginning of valid field values. For example, when querying a number-only field with a value such as “100”, the “” in the beginning will be ignored.
  • The filter object must contain all of its members. For example if you don’t use toval send an empty string but don’t send the filter without toval.

Example

{
 or: (number),
 ignorecase: (number),
 QueryValues:
 [{
   field: (string),
   fromval: (string),
   toval:  (string),
   op: (string),
   sort: (number),
   isdesc: (number),
 },
 {
   ...
 }]
}



QueryValue : Object

Properties

Name Type Description
field string The field to filter by.
fromval string Indicates the from value to filter
toval string Indicates the to/until value to filter
op string Filter operator. May be one of: =, <>, >=, <=, >, <
sort number Specifies whether the returned rows should be sorted by this field. Specify 0 or 1
isdesc number When sorting by this field, specify if the sort order is 1: descending or 0: ascending.



RowIndex : Object

Properties

Name Type Description
rowindex number The row index according to the operation.



Choose : Object

Properties

Name Type Description
ChooseLine Array of objects An array containing a list of ChooseLine objects
multi number If 1, indicates that the current choose field allows for multiple values to be selected. If 0, only one value can be chosen.
title1 string Each search result is described by two titles - a unique identifier value and a description. This is the title of the unique identifier value, e.g. ‘Type’.
title2 string Each search result is described by two titles - a unique value and a description. This is the title of the description, e.g. ‘Description’

Example

{
  title1: 'Type',
  title2: 'Description',
  alignright1: 0,
  alignright2: 0,
  multi: 0,
  ChooseLine: [
    { string2: '"Make" item', string1: 'P', retval: 'P' },
    { string2: '"Buy" item', string1: 'R', retval: 'R' },
    { string2: 'Other', string1: 'O', retval: 'O' }
  ],
  chooseid: '5943,6'
}

ChooseLine: Array of Objects

Properties

Name Type Description
string2 string Text describing the choose option
string1 string A brief code of this choose option
retval string The actual value returned to the field being updated. This is usually either ‘string1’ or ‘string2’.

Search : Object

Properties

Name Type Description
SearchLine Array of objects An array containing a list of SearchLine objects
cursor string The currently active ‘search-by’ method. See searchAction
ignorecase number If 1, indicates that the ignore case flag was active for this search. Else, the flag is off. See searchAction.
ismulti number If 1, indicates that the current search field allows for multiple values to be selected. If 0, only one value can be chosen.
lines number The number of search results retrieved in the current Search object.
next number Indicates whether there are more search results that can be retrieved. If 1, additional results can be retrieved with searchAction. Else, there are no more results to fetch.
start number If 1, indicates that the ‘match start’ flag was active for this search. Else, the flag is off. See searchAction.
value string The search pattern used to retrieve these results.



SearchLine : Array of Objects

Properties

Name Type Description
string1 string The result’s unique identifier value. For example, if in Search, title1 is ‘Customer Number’, this might be ‘CUST001’
string2 string The result’s description value. For example, if in Search, title2 is ‘Customer Name’, this might be ‘Blue Construction Inc.’
string3 string An optional field that may contain additional description value.
retval string The actual value returned to the field being updated. This is usually either ‘string1’ or ‘string2’.



FileProgress : Object

This object is obtained through UploadFileProgressCallback and shows the progress of the upload.

Properties

Name Type Description
progress number A number between 0 and 100 indicating the progress of the upload.



FileResult : Object

This object is obtained when UploadFile resolves, and provides the file’s url on the Priority server.

Name Type Description
file string The file’s url on the Priority server.