6.5.2 Action scripts (UI Version 1.1)
The script specified by the “file” label in the Script YAML file must be created in advance. Please write the script in JavaScript. The following is a list of action execution timings for each component and the names of functions that are called. The customer should define the function name in the corresponding script and write the contents of the action.
(Table) List of execution timings for each component and function names (UI Version 1.1)
| Component | Action execution timing |
Name of function called in the script |
Function arguments | ||
|---|---|---|---|---|---|
| Data format | Variable name | Value to be set | |||
| Grid | When the window is displayed | handleLoad | - | - | - |
| Button | When the button is clicked | handleClick*1 | string | name | Name of the clicked button |
| Immediately after the button is clicked | handleBeforeAction*2 | - | - | - | |
| Before saving data | handleBeforeSave*2 | - | - | - | |
| After saving data | handleAfterSave*2 | - | - | - | |
| Before proceeding to the next step in the workflow | handleBeforeRequestWorkflow*2 | - | - | - | |
| handleBeforeResumeStep*2 | - | - | - | ||
| Form | When the window is displayed | handleLoad | - | - | - |
| When obtaining the initial field of a Form | handleAfterLoadData | - | - | - | |
| When changing a field in a Form | handleChange | string | fieldName | Name of the changed field | |
| any | fieldValue | Value of the changed field | |||
| Object | fieldExtension | Value of the changed field | |||
| boolean | fieldExtension.checked | Checkbox On/Off (when properties.checkbox: true) | |||
| string | fieldExtension.operator | Operator (when properties.operator: true) | |||
| any | fieldExtension.firstOperand | First operand (when properties.operator: true, none depending on the operator) | |||
| any | fieldExtension.secondOperand | Second operand (when properties.operator: true, none depending on the operator) | |||
| When focus is lost | handleBlur | string | fieldName | Name of the changed field | |
| any | fieldValue | Value of the changed field | |||
| Object | fieldExtension | Value of the changed field | |||
| boolean | fieldExtension.checked | Checkbox On/Off (when properties.checkbox: true) | |||
| string | fieldExtension.operator | Operator (when properties.operator: true) | |||
| any | fieldExtension.firstOperand | First operand (when properties.operator: true, none depending on the operator) | |||
| any | fieldExtension.secondOperand | Second operand (when properties.operator: true, none depending on the operator) | |||
| Table | Change Table row selection | handleSelectionModelChange | GridRowId[] or GridRowId | selectModel | When the properties.selection: of the Table component is "checkbox", it is an array of the IDs of the selected rows, and when it is "radio", it is the ID of the selected row |
| When clicking on a cell | handleCellClick | string | field | Column name of the clicked column | |
| object | row | Row data for the clicked row | |||
| When the cell value changes | handleCellValueChange | any | value | Entered value | When clicking on the cell icon | handleIconClick | Object | row | Row data for the clicked row |
| Tabs | When the tab selection changes | handleChange | string | name | Name of the selected tab |
| object | activeTab | Information on the selected tab | |||
| When tab is active | handleActivate | string | name | Name of the tab that has become active | |
| object | activeTab | Information on the tab that has become active | |||
| When tab is inactive | handleDeactivate | string | name | Name of the tab that has become inactive | |
| object | activeTab | Information on the tab that has become inactive | |||
| When clicking the Add Tab button | handleAddButtonClick | Array.<object> | - | List of information on displayed tabs | |
| Card | When the Card is clicked | handleClick*3 | string | name | Name of the clicked card |
| When the window is displayed | handleLoad | - | - | - | |
The following is a list of function names that can be used when describing the contents of an action.
[Static functions]
- OIWindow
- OIData
- OIWorkflow
- OIApi
- OICommon
- OIUi
[Create and use an instance of each class]
The values in parentheses () here indicate the arguments when the instance is created.
- OIActionButton (action button name)
- OIButton (button name, name space)
- OIApiDataSource (data source name, name space)
- OITableDataSource (data source name, name space)
- OIForm (form name, name space)
- OITable (table name, name space)
- OITabs (tab name, name space)
- OITab (tab name, name space)
- OIArticle (article name, name space)
- OIAttachment (attachment name, name space)
- OICard (card name, name space)
(Table) List of function names that can be used when describing the contents of an action (UI version 1.1)
| Class name | Function name | Function arguments | Content of action | |||
|---|---|---|---|---|---|---|
| Data format | Variable name | Value to be set | ||||
| OIWindow | open | string | - | type | Specify "move", "new_window", or "new_tab".
|
Open a page or UI. |
| Object | options | - | ||||
| string | url | Specify the URL of the page to be displayed in "url". Example) {url:'/sys_task'} |
||||
| OIWindow | showMessage | string | - | type | Specify "snackbar" to display messages in a snackbar, or "modal" to display messages in a dialog box. | Display a snackbar or message dialog box. If "modal" is specified for type, when the first button is clicked, "ok" is set as the return value, and when the last button is clicked, "cancel" is set as the return value in Promise<string> type. |
| Object | options | - | ||||
| string | typeMess | If the type is "snackbar", specify "error", "warning", "info", or "success". If the type is "modal", any number of buttons can be displayed, and it is possible to determine which button was clicked by receiving the return value. | ||||
| string | content | Specify the message that is displayed. | ||||
| string | title | If the type is "modal", specify a title. | ||||
| [Array<Object>] | buttons | If the type is "modal", set the button label and value (returned when clicked) as follows.
- [Array<Object>] buttons - {string} name - {string} value |
||||
| Object | btnOk | If the type is "modal", set the content to be displayed in the label of the first button. | ||||
| string | btnCancel | If the type is "modal", set the content to be displayed in the label of the last button. If both btnOk and btnCancel are omitted, the "OK" button will be displayed. |
||||
| string | subContent | If the type is "modal", set an additional message to be displayed below the content message. Can be omitted. | ||||
| boolean | useConfirm | If the type is "modal" and "true" is specified, a confirmation checkbox is added for clicking the "OK" button. If omitted, it becomes "false". | ||||
| OIWindow | resetScroll | - | - | - | - | Reset the scroll position of the content area. |
| OIData | insertCurrentRecord | Object | currentRecord | - | Insert records into any table in the database using Ops I REST API graphql. Set the Response Body as a Promise<Object> type in the return value. | |
| string | table | Specify the table name into which the record will be inserted. | ||||
| Object | Field name of the inserted record | Specify the value to be set in the field of the inserted record. Any number can be specified, but it must correspond to the field name of the table where it is to be inserted. The value to be set should match the field type; for example, "string" for a string field, or "number" for a numeric field. | ||||
| string | - | ctxId | Specify the context ID to be associated with the record to be inserted. | |||
| OIData | getRecords | string | - | tableName | Specify the table name of the record to be obtained. | Uses the Ops I REST API graphql to obtain records from any table in the database, and set the Response Body as a Promise<Object> type in the return value. |
| string | - | obj | Specify the GraphQL query for the record obtain condition. Example 1) When specifying the fields to be obtained: '{field1 field2}' Example 2) When obtaining field1 and field2 for the same record as the specified record ID: '( where: { id: {_eq: "record ID" } }){field1 field2}}' |
|||
| OIData | updateCurrentRecord | Object | currentRecord | - | Uses the Ops I REST API graphql to update any record in a table in the database, and sets the Response Body as a Promise<Object> type in the return value. | |
| string | table | Required. Specify the table name of the record to be updated. | ||||
| string | id | Required. Specify the ID of the record to be updated. | ||||
| Object | Field name of the updated record | Specify the value to be set in the field of the record to be updated. Any number can be specified, but it must correspond to the field name of the table where it is to be updated. The value to be set should match the field type; for example, "string" for a string field, or "number" for a numeric field. | ||||
| OIData | deleteCurrentRecord | string | - | tableName | Specify the table name of the record to be deleted. | Uses the Ops I REST API graphql to delete any record from a table in the database, and sets the Response Body as a Promise<Object> type in the return value. |
| string | - | currentId | Specify the ID of the record to be deleted. | |||
| OIData | query | Object | query | - | Use the Ops I REST API graphql to execute any GraphQL query and set the Response Body as a Promise<Object> type in the return value. | |
| string | query | Specify the GraphQL query to be executed as a string. | ||||
| Object | variables | Specify variables to be embedded in the GraphQL query. | ||||
| OIWorkflow | respond | string | - | contextID | Context ID | Responds to the workflow and sets the execution result as the return value of the Promise<Object> type. |
| string | - | activityName | Reply activityName (Task name specified in tasks in the workflow definition) | |||
| Object | - | params | Specifies one of the following as the action to be taken in response: "accept", "reject", "pull_back", or "cancel". Example) { "oi_response": "accept" } |
|||
| OIWorkflow | start | string | - | contextID | Context ID | Executes the workflow associated with the specified context ID and sets the execution result as the return value of the Promise<Object> type. |
| Object | - | body | Specifies the contents of the parameters to be set in the workflow. Example) { "params": { "param1": "string", "param2": "string", "param3": "string" } } |
|||
| OIWorkflow | getActivity | - | - | - | - | Obtains the object (StackStorm step object) of the activity in the currently displayed workflow as a Promise<Object> type. Returns a Promise that waits until it is obtained. |
| OIApi | call | string | - | url | Specify the URL of the REST API to be executed. The REST API you specify must have a Response Body in JSON format. | Execute the REST API and set the Response Body as a Promise<Object> type in the return value. |
| Object | - | option | Specify the parameters. If omitted, {} is set. Example) {method: 'GET', headers: {'Content-Type': 'application/json'} |
|||
| boolean | - | showError | Specify whether to display error details on the window when an error occurs in REST API. If omitted, will be set to "true". | |||
| OICommon | getUserProfile | - | - | - | - | Obtains the profile of the logged-in user and sets it as a Promise<UserPrincipalDTO> type in the return value. UserPrincipalDTO contains the following information.
|
| OICommon | getDateWithUserTimezone | - | - | - | - | Obtains the current date and time (YYYY-MM-DDTHH:mm:ssZ) in the time zone of the logged-in user and sets it as a string in the return value. Example) 2022-09-21T15:36:20+09:00 |
| OICommon | translate | Object | - | dictionary | Define character strings for each language. | Returns a string matching the user's language settings. |
| string | - | key | Specify the key to be obtained from the dictionary. | |||
| OICommon | showLoadingScreen | - | - | - | - | Displays the lock window. The counter is incremented by the number of executions. |
| OICommon | hideLoadingScreen | - | - | - | - | Removes the lock window display. The counter is decremented by the number of executions, and the display is removed when the counter reaches 0. To avoid the window becoming unresponsive and staying on the lock window, use a try-finally clause, etc., to set it so that hideLoadingScreen is always called even in the event of an error. If the lock window is not displayed when this method is called, this method will have no effect on the window and it will close normally. |
| OICommon | copyClipboard | string | - | data | Specify a string to paste to the clipboard. | Pastes the specified string to the clipboard. |
| OICommon | getLocation | - | - | - | - | Obtains current position information for the current document using Window.location (Web API built into the browser), and sets the return value as the following Promise<Object> type.
|
| OIUi | getContext | - | - | - | - | Obtains context information and sets the following as a Promise<Object> type in the return value.
|
| OIActionButton | setVisible | boolean | - | isVisible | Specify "true" (show) or "false" (hide). | Sets whether to show or hide buttons. Returns a Promise<undefined> that waits until the setting is complete. |
| OIActionButton | setEnable | boolean | - | isEnable | Specify "true" (active) or "false" (inactive). | Sets whether a button is active or inactive. Returns a Promise<undefined> that waits until the setting is complete. |
| OIButton | setVisible | string | - | buttonName | Name of the target button in the button list | Sets whether to show or hide buttons. Returns a Promise<undefined> that waits until the setting is complete. |
| boolean | - | isVisible | Specify "true" (show) or "false" (hide). | |||
| OIButton | setEnable | string | - | buttonName | Name of the target button in the button list | Sets whether a button is active or inactive. Returns a Promise<undefined> that waits until the setting is complete. |
| boolean | - | isEnable | Specify "true" (active) or "false" (inactive). | |||
| OIApiDataSource | refresh | boolean | - | loading | Whether loading icons are displayed (when omitted: not displayed) | The data is obtained again and the obtained data is reflected in the places where the data source is used. Returns a Promise<undefined> that waits until complete. |
| OIApiDataSource | setAutorefreshSeconds | number | - | secondsValue | Specify the automatic refresh interval (seconds) as an integer. | Sets the automatic refresh interval. Returns a Promise<undefined> that waits until complete. |
| OIApiDataSource | getParameter | string | - | paramName | Specify the parameter name for the specified data source name. | Obtains the parameter settings for the specified data source name as a Promise<APIDataSourceParameter>type or Promise<undefined>. If it does not match the specified paramName, Promise<undefined> is returned. |
| OIApiDataSource | setParameter | string | - | paramName | Specify the parameter name for the specified data source name. | Sets the parameter for the specified data source name (overwrites if the specified parameter exists, creates if it does not). Returns a Promise<undefined> that waits until complete. |
| APIDataSourceParameter | - | parameter | Specify the parameter object to be updated. Example: { type: ' fixed' , value: ' true' , } Specify the type as "fixed", "query", or "uipath", and the value as a string. Null and undefined can also be specified. |
|||
| OIApiDataSource | deleteParameter | string | - | paramName | Specify the parameter name for the specified data source name. | Deletes the parameter configuration for the specified data source name. Returns a Promise<undefined> that waits until complete. |
| OIApiDataSource | update | boolean for loading or showError, function for overrideRequestBody | - | options | Specify the following.
|
Updates the resource referenced by the API data source. Returns a Promise that waits until complete. |
| OIApiDataSource | create | Creates the resource referenced by the API data source. Returns a Promise that waits until complete. | ||||
| OIApiDataSource | delete | Deletes the resource referenced by the API data source. Returns a Promise that waits until complete. | ||||
| OITableDataSource | refresh | boolean | - | loading | Whether loading icons are displayed (when omitted: not displayed) | The data is obtained again and the obtained data is reflected in the places where the data source is used. Returns a Promise<undefined> that waits until complete. |
| OITableDataSource | setAutorefreshSeconds | number | - | secondsValue | Specify the automatic refresh interval (seconds) as an integer. | Sets the automatic refresh interval. Returns a Promise<undefined> that waits until complete. |
| OITableDataSource | getParameter | string | - | paramName | Specify the parameter name for the specified data source name. | Obtains the parameter settings for the specified data source name as a Promise<TableDataSourceParameter> type or Promise<undefined>. If it does not match the specified paramName, Promise<undefined> is returned. |
| OITableDataSource | setParameter | string | - | paramName | Specify the parameter name for the specified data source name. | Sets the parameter for the specified data source name (overwrites if the specified parameter exists, creates if it does not). Returns a Promise<undefined> that waits until complete. |
| TableDataSourceParameter | - | parameter | Specify the parameter object to be updated. Example: { type: ' fixed' , value: ' true' , } Specify the type as "fixed", "query", or "uipath", and the value as a string. Null and undefined can also be specified. |
|||
| OITableDataSource | deleteParameter | string | - | paramName | Specify the parameter name for the specified data source name. | Deletes the parameter configuration for the specified data source name. Returns a Promise<undefined> that waits until complete. |
| OITableDataSource | update | boolean | - | options | Specify the following.
|
Updates the resource referenced by the Table data source. Returns a Promise that waits until complete. |
| OITableDataSource | create | Creates the resource referenced by the Table data source. Returns a Promise that waits until complete. | ||||
| OITableDataSource | delete | Deletes the resource referenced by the Table data source. Returns a Promise that waits until complete. | ||||
| OIForm | setStatus | string | - | field | Specify the target field name for which the status is to be set. | Set the status of the field in the form. Only field types with a function to output validation errors are supported. Returns a Promise<undefined> that waits until the value of the argument status is reflected in the target field. |
| string | - | status | Set the status. Setting "error" will result in an error state, and setting anything else will cancel the error state. | |||
| OIForm | setHelperText | string | - | field | Specify the target field name for which the helper text is to be set. | Set the helper text for the form field. Only field types with a function to output validation error messages are supported. Returns a Promise<undefined> that waits until the value of the argument helperText is reflected in the target field. |
| string | - | helperText | Set the helper text. | |||
| OIForm | removeHelperText | string | - | field | Specify the field name for which the helper text is to be deleted. | Delete the helper text for the form field. Only field types with a function to output validation error messages are supported. Returns a Promise<undefined> that waits until the value of the argument helperText is deleted from the target field. |
| OIForm | getFieldValue | string | - | fieldName | Specify the field name. | Obtains the field value is returned as Promise<object> type. |
| OIForm | getFieldValues | - | - | - | - | All field values are returned as Promise<object> type. |
| OIForm | getFieldExtension | string | - | fieldName | Specify the field name. | Obtains various field information is returned as Promise<object> type. |
| OIForm | getFieldExtensions | - | - | - | - | All field information is returned as Promise<object> type. |
| OIForm | setFieldValue | string | - | fieldName | Specify the field name. | Sets the field values. Returns a Promise<undefined> that waits until the value of the argument fieldValue is reflected in the target field. |
| any | - | fieldValue | Specify the field value. | |||
| OIForm | setFieldExtensions | string | - | fieldName | Specify the field name. | Sets various field information. Returns a Promise<undefined> that waits until the value of the argument extensions is reflected in the target field. |
| object | - | extensions | Specify various field information. | |||
| OIForm | setFieldVisible | string | - | fieldName | Specify the field name. | Sets whether to show or hide a field. Returns a Promise<undefined> that waits until the setting is complete. |
| boolean | - | visibility | Specify whether to show or hide a field. | |||
| OIForm | validate | - | - | - | - | Returns the Form validation result as a Promise<boolean> type.
|
| OIForm | setLookupLabelQuery | string | - | fieldName | Specify the target field name. | Sets the labelQuery for the target lookup field. Returns a Promise<undefined> that waits until the setting is complete. |
| string | - | value | Specify the labelQuery for the lookup field. | |||
| OIForm | getLookupLabelQuery | string | - | fieldName | Specify the target field name. | Obtains the labelQuery for the target field. If the target field is not a lookup field, or if the labelQuery property is omitted, a Promise<undefined> is returned. |
| OIForm | setEnable | boolean | - | isEnable | Specify "true" (active) or "false" (inactive). | Sets whether the target form is active or inactive. Returns a Promise<undefined> that waits until the setting is complete. |
| OIForm | setFieldEnable | string | - | fieldName | Specify the target field name. | Sets whether the target field is active or inactive. Returns a Promise<undefined> that waits until the setting is complete. |
| boolean | - | isEnable | Specify "true" (active) or "false" (inactive). | |||
| OITable | getSelectedRows | - | - | - | - | Obtains all data in the selected row of the table and returns it as a Promise<object> type. |
| OITabs | getTabs | - | - | - | - | Obtains an array of all tab information belonging to an instance. Tabs with a visible property of false in the "type: tab" component of the UI YAML file are not included in the array. The return value will be of the same type as the argument of the addTab function. |
| OITabs | addTab | object | - | params | Specify the parameters of the tab to be added. | Adds the specified tab. Returns a Promise<undefined> that waits until the addition is complete. The following will result in a TypeError.
|
| string | - | params.name | Specify the name of the tab to be added. This specifies the name of the Tab component in the UI YAML file. | |||
| string | - | params.id | Specify the internal ID of the tab. Must be unique within the tabs. If omitted, an ID will be automatically assigned. | |||
| string | - | params.label | Specify the label of the tab. If omitted, a label will be automatically assigned. | |||
| boolean | - | params.visible | Specify "true" (show) or "false" (hide). Default is "true". | |||
| string | - | params.queryParameter | Specify the query parameter to be added to the current URL when the tab becomes active in the "key=value" format. | |||
| object | - | params.state | Sets the tab status. | |||
| OITabs | activateTab | number | - | index | Specify the index of the tab to be made active. The default value is 0. | Makes the specified tab active. If index is not an integer, it will result in a TypeError. Returns a Promise<undefined> that waits until the active setting of the tab for the specified index is complete. |
| OITabs | getActiveTab | - | - | - | - | Obtains the active tab. Returns a Promise<undefined> if the active tab is 0. |
| OITab | getForm | string | - | name | Specify the name of the form on the tab. | Obtains the OIForm instance contained in the content associated with the tab. |
| OITab | getTable | string | - | name | Specify the name of the table on the tab. | Obtains the OITable instance contained in the content associated with the tab. |
| OITab | getTabs | string | - | name | Specify the name of the tab on the tab. | Obtains the OITabs instance contained in the content associated with the tab. |
| OITab | getArticle | string | - | name | Specify the name of the article on the tab. | Obtains the OIArticle instance contained in the content associated with the tab. |
| OITab | getButton | string | - | name | Specify the name of the button on the tab. | Obtains the OIButton instance contained in the content associated with the tab. |
| OITab | getAttachment | string | - | name | Specify the name of the attachment on the tab. | Obtains the OIAttachment instance contained in the content associated with the tab. |
| OITab | getCard | string | - | name | Specify the name of the card on the tab. | Obtains the OICard instance contained in the content associated with the tab. |
| OIArticle | setAutorefreshSeconds | number | - | secondsValue | Automatic refresh interval (seconds) | Sets the automatic refresh interval. Returns a Promise<undefined> that waits until the setting is complete. If secondsValue is not an integer, it will result in a TypeError. |
| OIAttachment | saveFiles | - | - | - | - | Saves the attachment. Returns a Promise<undefined> that waits until the save is complete. If secondsValue is not an integer, it will result in a TypeError. |
| OICard | setContent | string | - | content | Specify the displayed content. | Sets the displayed content. Returns a Promise<undefined> that waits until the setting is complete. If secondsValue is not an integer, it will result in a TypeError. |
| OICard | setLink | string | - | link | Specify the link destination. | Sets the link destination. Returns a Promise<undefined> that waits until the setting is complete. If secondsValue is not an integer, it will result in a TypeError. |
<Definition example>
async function handleCellClick(_, row) {
const ticketID = row.id;
const tabs = new OITabs('ticket_tabs');
const tabDetails = await tabs.getTabs();
const existingTicketTabIndex = tabDetails.findIndex(
(detail) => detail.id === ticketID,
);
if (existingTicketTabIndex !== -1) {
tabs.activateTab(existingTicketTabIndex);
} else {
tabs.addTab({
name: 'ticket_detail_tab',
id: ticketID,
label: row.number,
queryParameter: 'id=${ticketID}',
});
}
}