Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Within UI action script, you can use some specific global methods allows expanding interaction possibilities. Use them to extend standard UI action functionality.
Example 1
When the Wait server response is selected, the system waits 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() methodsto make the UI action available again after the action is taken. For example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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, for example, do not wait for the button to become available.
Use the __rejectServerResponse() method to handle errors.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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
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.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const rowRecordId = window.currentCell.recordId; const rowTableName = window.currentCell.tableName; if (rowRecordId) { s_go.open(`/record/${rowTableName}/${rowRecordId}`); } |
Note |
---|
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) table, 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:
- Open any list containing any values.
- Open developer console in your browser.
- Right-click any cell to get a context menu.
- In the developer console, type window.currentCell and submit.
Field | Description |
---|---|
attribute | A type of item from which information is gathered. When a cell in the list header is selected, then this field is populated with the value similar to the fieldName field. |
columnId | ID of the column to which the specified field is related. |
columnType | Type of the column to which the specified field is related. |
recordId | ID of the record. |
tableId | ID of the table containing specified field and record. |
tableName | System name of the table containing specified field and record. |
value | Current cell value. |
Example 3
In this example, consider 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.
The UI action code example is listed belowthe following:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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.'); } |