User interface (UI) actions are buttons, links, and context menu items on forms and lists. They allow you to customize the UI to be more interactive, adjustable, and comfortable for working.
Role required: admin. |
In SimpleOne, the UI actions can be inherited and then you can override their logic, scripts, order, name, or any other feature.
The system provides UI Actions inheritance with the Inherits option. When a UI action has a Table specified, and the Inherits checkbox is selected, the system applies this UI action to all child tables of the table specified before. For child UI actions, the reference Parent option defines a parent UI action with functionality options that can be overridden if necessary. |
To inherit a UI action, complete the steps below:
To override a UI action, complete the steps below:
You can create new or customize existing UI actions.
To do this, complete the following steps:
You can edit some types of UI actions like buttons, links in a quick way. To do this, complete the steps below:
|
You can make a UI action display on all tables.
To do that, follow the steps below:
Most hamburger menu items and some buttons on forms (New, Save, Save and Exit) and on lists (New, Delete) are global. |
The UI action functionality allows you to create multi-level submenu options by embedding items to the hamburger menu within forms and lists.
This option is only available for the UI actions of the Hamburger Menu type. |
To embed a UI action, follow the steps below:
The condition option defines situations when UI actions displayed. The Condition field expects using server-side API, but in some cases, it is possible to apply client-side API. To enable client script use, on the UI action form, select the Client checkbox. In the Condition field, use the current object to access a UI action. This object can only be used for UI actions that are displayed on forms.
Call the current object within the UI actions during the update since this object is defined. When creating a new UI action, the current value is NULL. |
Use logical operators && (AND) and || (OR) to compose the complex conditions.
Conditions allow you to call the server-side Script Includes created. In the example below, the function wfContextExists() of Script Include with the same name gets current.sys_id and current.getTableName as recordID and tableName arguments.
The ss object allows you to call the SimpleSystem methods. |
This UI action is a reference to the record with the sys_id of the getTableName table. If a record exists, the function returns true, and it returns false when there is no record found. Depending on the value returned, the function displays the UI action or not.
function wfContextExists(recordID, tableName){ const table = new SimpleRecord('sys_db_table'); table.get('name', tableName); const wfContext = new SimpleRecord('wf_context'); wfContext.addQuery('related_record_id', ss.getDocIdByIds(table.sys_id, recordID)); wfContext.selectAttributes('sys_id'); wfContext.query(); return (wfContext.getRowCount() > 0) } |
The Script field defines the UI action behavior. By default, this field supports the Server-Side API. Select the Client checkbox to switch the available API to the Client-Side API.
For example, this UI action adds an informational message with the Description field content:
ss.addInfoMessage(current.description); |
When the current object is called, it is not necessary to use the initialize() method; the object context is already initiated. |
Field | Mandatory | Description | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name | Y | Specify a UI action name. This text is displayed on the button, link, or as a context menu item. | ||||||||||||||||||||||||||
Table | Y | Specify a table to display UI action on. | ||||||||||||||||||||||||||
Parent | N | Specify the context menu item to be a parent for the current UI action (applicable for the Hamburger Menu UI action type). | ||||||||||||||||||||||||||
Comments | N | Type the action brief description. | ||||||||||||||||||||||||||
Active | N | Select this checkbox to make the UI action to be displayed on a form (list, context menu). | ||||||||||||||||||||||||||
Inherits | N | Select this checkbox to make this UI action available for all child tables of the table specified in the Table field. | ||||||||||||||||||||||||||
Order | N | Specify the order of the displaying. If there are UI actions of the same type, they are arranged in the ascending order. | ||||||||||||||||||||||||||
Overrides by | N | Specify a UI action that will be overridden by the current UI action.
| ||||||||||||||||||||||||||
Conditions and Actions | ||||||||||||||||||||||||||||
Show Insert | N | Select this checkbox to display this UI action on a new record form. | ||||||||||||||||||||||||||
Show Update | N | Select this checkbox to display this UI action on an existing record form. | ||||||||||||||||||||||||||
Wait Server Response | N | Select this checkbox to specify that the system should wait for the server response after the button is clicked. The button is disabled until the server responds. | ||||||||||||||||||||||||||
Client | N | Select this checkbox to specify that this UI action is only performed on the client side (in the user's browser). | ||||||||||||||||||||||||||
Condition | N | Specify a condition using server-side API. If this condition is met, the Script is executed. | ||||||||||||||||||||||||||
Script | N | Specify a script that is executed by clicking the UI action. | ||||||||||||||||||||||||||
URL | N | Specify a URL that is displayed after clicking the UI action. You can use variables listed below:
| ||||||||||||||||||||||||||
Position and Style | ||||||||||||||||||||||||||||
Use for | N | In this block of fields, choose options defining where this UI action should be displayed. Available options are: List type:
If Lists+Related Lists or Related Lists options are selected, then a set of checkboxes appears where you can define on which related list types this UI action can be displayed. You can select more than one option. These options display relation types between related list elements and the parent table. For example: the User Criteria related list contains the Users field of the List type. This field is related with the Users (user) table, so this related field is of the List field type. By selecting and unselecting appropriate checkboxes, you can place UI action you are creating on related list of corresponding type.
| ||||||||||||||||||||||||||
Form buttons | ||||||||||||||||||||||||||||
Form Style | N |
| ||||||||||||||||||||||||||
Header Left | N | Button in the form header on the left. | ||||||||||||||||||||||||||
Header Right | N | Button in the form header on the right. | ||||||||||||||||||||||||||
Hamburger Menu | N | Context menu item on the form. | ||||||||||||||||||||||||||
Field Label Context Menu | N | An item of the context menu for the fields on the form. | ||||||||||||||||||||||||||
Link | N | Link on the form. | ||||||||||||||||||||||||||
Bottom | N | Button at the bottom of the form. | ||||||||||||||||||||||||||
List Buttons | ||||||||||||||||||||||||||||
List Style | N |
| ||||||||||||||||||||||||||
Header Left | N | Button in the list header on the left. | ||||||||||||||||||||||||||
Header Right | N | Button in the list header on the right. | ||||||||||||||||||||||||||
Hamburger Menu | N | A hamburger menu item on the list. | ||||||||||||||||||||||||||
Column Header Context Menu | N | A context menu item for the elements of the list. | ||||||||||||||||||||||||||
Row Context Menu | N | Context menu item on the list. | ||||||||||||||||||||||||||
Link | N | Link on the bottom of the list. | ||||||||||||||||||||||||||
Bottom | N | Button at the bottom of the list. | ||||||||||||||||||||||||||
Button Context Menu | N | A context menu item for UI actions of the button type. | ||||||||||||||||||||||||||
Dependency Map Context Menu | N | Menu item on the service model form. |
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 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:
await s_i18n.getMessage('The report has been saved', (response) => { s_form.addInfoMessage(response); __resolveServerResponse(); }); |
Use the __resolveServerResponse() method to force the server respond, so, for example, do not wait for the button to become available.
Use the __rejectServerResponse() method to handle errors.
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 in the format of an object containing the information about the cell.
const rowRecordId = window.currentCell.recordId; const rowTableName = window.currentCell.tableName; if (rowRecordId) { s_go.open(`/record/${rowTableName}/${rowRecordId}`); } |
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. After all changes, save the page. |
To get this information manually, complete the steps below:
Field | Description |
---|---|
attribute | A 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. |
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, сonsider a case of bulk deletion of records that were selected on the list view.
To do this, a currents object is used. It is intended to store 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 list UI actions.
The UI action code example is listed below:
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.'); } |