Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
The widget API describes SimpleWidget and SimpleWidgets client-side classes provide the methods for widget structure and functionality customization:
Use the s_
widget andwidget object of the SimpleWidget class to implement the required functionality. The object becomes available when a widget you create is initialized.
Use the s_widgets object
methods in the client-side scriptsof the
widgetsSimpleWidgets class to implement the required functionality. The object is initialized when you add a widget to a form or a portal page.
To create your own widget methods, use the s_widget_custom.
Info These methods can only be used on the client-side.
Note |
---|
s_widget is an object of the SimpleWidget class that becomes available when a widget you create is initialized. s_widgets is an object of the SimpleWidgets class, initialized when you add a widget to a form or a portal page. |
SimpleWidget
s_widget
To Use the s_widget object to perform the current widget customization , use with the methods below.
Info | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
In the console, to To manually invoke the method, pass the widget instance ID as the first parameter in the console. For example, to call the following method:
use the following approach:
|
s_widget.addTemplate(id, template, script, type)
This Use this method adds to add a child template to the existing template by its ID with one of the following types: inner, before, after.
Parameters:
Name | Type | Mandatory | Default value | |||||
---|---|---|---|---|---|---|---|---|
id | String | Y | N | |||||
template | String | Y | N | |||||
script | String | N
| N | |||||
type | String (possible | N | inner
| )N | inner
|
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
<div id="steps"></div> |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
s_widget.addTemplate('steps', '<div class="main">', '', 'inner'); |
s_widget.getElements()
This Use this method returns to return the widget structure elements collected in an array.
Return:
Type | Description |
---|
Array of <elements> | The widget structure elements are collected in an array. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_widget.getElements(); |
s_widget.getFieldValue(key)
Use this method to return the data value of the widget that is defined by the key option.
Parameter:
Name | Type | Mandatory | Default value |
---|---|---|---|
key | String | Y | N |
Return:
Type | Description |
---|---|
Any | The value of the field that is defined by the key. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_widget.getFieldValue('element'); |
s_widget.getId()
This Use this method returns to return a widget instance ID.
Return:
Type | Description |
---|---|
String | This method returns a widget instance ID. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_widget.getId(); |
s_widget.getOptionValue(key)
Use this method to return an option value that is defined by the key.
Parameter:
Name | Type | Mandatory | Default value |
---|---|---|---|
key | String | Y | N |
Return:
Type | Description |
---|---|
Any | A value of the widget option that is defined by the key. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
s_widget.getOptionValue('label'); |
s_widget.removeTemplate(id)
The Use the method removes to remove all child nodes and content from the specified element. It does not remove the element itself or its attributes.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
id | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<div id="element1"> Remove me </div> <button buttonType="approve" event-click="window.s_widget_custom.remove();"> Click meAdd </button> |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#element1 { background-color: yellow; height: 20px; } |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
; (() => { window.s_widget_custom = window.s_widget_custom || {}; window.s_widget_custom.remove = function () { s_widget.removeTemplate('element1'); } })(); |
s_widget.setFieldValue(key, value)
Use this method to set a value for the key.
Info |
---|
If the value parameter is equal to 'null', for example, |
Parameters:
Name | Type | Mandatory | Default value |
---|---|---|---|
key | String | Y | N |
value | Any | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
; (async () => { const tableName = s_form.getTableName(); const recordId = s_form.getUniqueValue(); const serviceId = s_form.getValue('service'); const serviceDisplayValue = s_form.getDisplayValue('service'); s_widget.setFieldValue('table_name', tableName); s_widget.setFieldValue('record_id', recordId); s_widget.setFieldValue('service', { database_value: serviceId, display_value: serviceDisplayValue }); await s_widget.serverUpdate(); })(); |
s_widget.serverUpdate()
With Use this method you can to transfer the data to a server, where the widget server script runs. As a result, the widget data is updated.
Return:
Type | Description |
---|---|
Object | This method returns a promise containing a server response. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
; (async () => { const tableName = s_form.getTableName(); const recordId = s_form.getUniqueValue(); s_widget.setFieldValue('table_name', tableName); s_widget.setFieldValue('record_id', recordId); const response = await s_widget.serverUpdate(); console.log(response.getData().data); })(); |
s_widget.setOptionValue(key, value)
Use this method to set a value using the key of the widget option.
Parameters:
Name | Type | Mandatory | Default value |
---|---|---|---|
key | String | Y | N |
value | Any | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
s_widget.setOptionValue('label', 'name'); |
s_widget.showData()
The method displays the data of a widget in the console.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
s_widget.showData(); |
SimpleWidgets
s_widgets
Invoke the methods of the s_widgets object within your scripts, when adding a widget to a form or a page for widget interaction.
s_widgets.getFieldValue(widgetInstanceID, key)
This Use this method returns to return the data value of the widget for the key and widget instance ID.
Parameters:
Name | Type | Mandatory | Default value |
---|---|---|---|
widgetInstanceID | String (the sys_id value) | Y | N |
key | String | Y | N |
Return:
Type | Description |
---|---|
Any | Returns the object value. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
s_widgets.getFieldValue('157555401214600424', 'name'); |
s_widgets.getForm()
This Use this method returns to return a form object that is placed using the <form> <Form> or <remform> tag.
Parameter:
Name | Type | Mandatory | Default value |
---|---|---|---|
name | String | Y | N |
Return:
Type | Description |
---|---|
Object | This method returns a SimpleForm object. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const builtInForm = s_widgets.getForm('custom'); await builtInForm.save(); |
s_widgets.getWidgets()
This Use this method returns to return a list of all the IDs of the widgets instances located on the page.
Return:
Type | Description |
---|---|
Array | A list of all the IDs of the widgets instances located on the page. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
s_widgets.getWidgets(); |
s_widgets.setFieldValue(widgetInstanceID, key, value)
Use this method to set a value for the key in the widget data, and the widget instance ID.
Parameters:
Name | Type | Mandatory | Default value |
---|---|---|---|
widgetInstanceID | String (the sys_id value) | Y | N |
key | String | Y | N |
value | Any | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
s_widgets.setFieldValue('157555401214600424', 'name', 'Alex'); |
Table of Contents | ||||
---|---|---|---|---|
|