Skip to main content
Version: 1.21.3

Use Cases

Within UI action script, you can use some specific global methods that expand interaction possibilities. Use them to extend standard UI action functionality.

Example 1: Make button available while the server responses


When using the Wait server response option, you define to wait for the server response after the button is clicked. The button is disabled between the button clicking and server responding.

Use the __resolveServerResponse() and __rejectServerResponse() methods to make the UI action available again after the action is taken. For example:

__resolveServerResponse()
await s_i18n.getMessage('The report has been saved', (response) => {
s_form.addInfoMessage(response);
__resolveServerResponse();
});

Use the __resolveServerResponse() method to force the server to respond, so not to wait for the button to become available.

Use the __rejectServerResponse() method to handle errors.

__rejectServerResponse()
const table = s_list.getTablesName()[0];
const selectedRows = s_list.getCheckedRow(table);
if (!selectedRows.length) {
await s_i18n.getMessage("No selected rows.", (translationResponse) => {
alert(translationResponse);
});
__rejectServerResponse();
}

Example 2: Get an information of a current cell


The currentCell property is used on lists and provides service information about the current table cell. The information is provided as an object that contains the information about the cell.

currentCell
const rowRecordId = window.currentCell.recordId;
const rowTableName = window.currentCell.tableName;
if (rowRecordId) {
s_go.open(`/record/${rowTableName}/${rowRecordId}`);
}
caution

This property is available to use only on UI actions implementing Row context menu. To use it for the specified UI action, navigate to its record form within the UI actions (sys_ui_action) dictionary, open the record and select this checkbox first on the Position and Style tab. When all changes are done, save the page.

To get this information manually, complete the steps below:

  1. Open any list containing any values.
  2. Open developer console in your browser.
  3. Right-click any cell to get a context menu.
  4. In the developer console, type window.currentCell and submit.
FieldDescription
attributeA type of an item from which information is gathered.
When a cell in list header is selected, then this field is populated with the value similar as the fieldName field.
columnIdThe ID of the column to which the specified field is related.
columnTypeType of the column to which the specified field is related.
recordIdThe ID of the record.
tableIdThe ID of the table containing specified field and record.
tableNameThe system name of the table containing specified field and record.
valueThe current cell value.

Example 3: Delete selected records


In this example, сonsider a case of bulk deletion of records that were selected on the list view.

Use a currents object to store the selected records as SimpleRecord objects. This object can be used instead of the getCheckedRow() method on the server side. It is available for the server-side [UI actions of lists](.#UI action-types).

The UI action code example is listed below:

Delete selected records
if (currents.length) {
const record = new SimpleRecord(currents[0].getTableName());
record.addQuery('sys_id', 'in', currents.map(checkedRow => checkedRow.sys_id));
record.selectAttributes(['sys_id']);
record.query();
record.deleteMultiple();
ss.setRedirect(); // reload window
} else {
ss.addErrorMessage('No selected rows.');
}