To take full advantage of the REM functionality, perform some additional actions:
For example, you need to extend the Task (task) table with some attributes that allow you to handle some daily tasks. To do so, complete the following steps:
Create an extension model for this table.
Save the ID of the model. It will be used in the next steps. |
Create a form widget as described below and save it:
<rem modelId="{data.model_id}" tableName="{data.table_name}" recordId = "{data.record_id}" /> |
(() => { window.s_widget_custom = window.s_widget_custom || {}; const parameter = new URLSearchParams(window.location.search).get('model_id'); s_widget.setFieldValue('model_id', parameter); s_widget.setFieldValue('table_name', window.s_form.getTableName()); s_widget.setFieldValue('record_id', window.s_form.getUniqueValue()); })(); |
Navigate to the record form using the URL https://instance.example.com/record/task?model_id=XXXX. Replace the XXXX in the URL with the ID of the model you created in step 1.
As a result, a form that contains the attributes of the specified model is displayed.
Use RE model to display attributes of some record on the form you need. For example, you need to see information about the user who initiated a task. This information is in REM attributes for the User (user) table. Here, you can add read-only REM attributes of the User (user) table to the Task (task) table. That is, you can display RE models of table A on the forms of table B.
To do so, configure the following entities:
To do this, complete the following steps:
Create a widget for the User (user) table with the following values:
Active | true (selected) |
---|---|
Tables | User |
<rem modelId="{data.model_id}" tableName="{data.table_name}" recordId = "{data.record_id}" /> |
( () => { window.s_widget_custom = window.s_widget_custom || {}; const parameter = new URLSearchParams(window.location.search).get('model_id'); s_widget.setFieldValue('model_id', parameter); s_widget.setFieldValue('table_name', window.s_form.getTableName()); s_widget.setFieldValue('record_id', window.s_form.getUniqueValue()); })(); |
Create a RE model with the attributes you need for the User (user) table.
Save the ID of the model. It will be used in the next steps. |
Navigate to the record form using the URL looking like: Navigate to the record form using the URL https://instance.example.com/record/task?model_id=XXXX. Replace the XXXX in the URL with the ID of the model you created in step 2.
Create a widget for the Task (task) table with the following values:
Active | true (selected) |
---|---|
Tables | Task |
<div> <rem modelId="{data.model_id}" tableName="{data.table_name}" recordId = "{data.record_id}" readOnly="true"/></rem> </div> |
( () => { s_widget.setFieldValue('table_name', 'user'); s_widget.setFieldValue('model_id', '{id of the RE model created on Step 2}'); s_widget.setFieldValue('record_id', '{id of the User record created on Step 4}'); })(); |
As a result, the Task form has read-only values of REM attributes from the User record.
The purpose of this case is to enable an employee to select the required type of task with its unique attributes when filling in the Task record form. To do so, you need to create a model for the Task table that refers to other models of the same table.
To do so, complete the following steps:
Create model client script. Navigate to Record Extended Model → Model Client Scripts and create a script with the attribute values described below.
Attribute | Value | |
---|---|---|
Name | Specify the script name, for example, Change model. | |
Container | Select the Task type model created earlier. | |
Type | onChange | |
Attribute | Select the Specify task type (related_model) attribute created earlier. | |
Active | Yes | |
Script | Create a script using the emit(eventType, data) method of the SimpleEventBus class. This script launches the modelChanged event when a model changes, assigning the value of the selected model to the Specify task type (related_model) attribute.
|
Widget for the model selection
<div simple-if="{data.visible}"> <remform modelId="169936967202653693" tableName="{data.table_name}"></remform> </div> |
remform modelId
– specify the ID of the Task type model created earlier.
( () => { s_widget_custom = s_widget_custom || {}; s_widget.setFieldValue('table_name', s_form.getTableName()); s_widget.setFieldValue('visible', !s_form.getUniqueValue()); })(); |
Widget for the model displaying
<rem modelId="{data.model_id}" tableName="{data.table_name}" recordId="{data.record_id}"></rem> |
( () => { s_widget_custom = window.s_widget_custom || {}; SimpleEventBus.on('modelChanged', (data) => { if (!s_form.getUniqueValue()){ s_widget.setFieldValue('model_id', data); } }); s_widget.setFieldValue('table_name', s_form.getTableName()); s_widget.setFieldValue('record_id', s_form.getUniqueValue()); })(); |
Create widget instances. Navigate to Portal Structure → Widget Instances and create an instance for each widget created earlier.
Attribute | Value |
---|---|
Widget | Select the widget the instance of which you need to create. |
Order | Specify the widget order on the page. It is recommended to set the order of the displaying widget bigger than the one of the selection widget so that the attributes of the selected model are displayed below its name. |
Schema Option Values | [] |
Active | true |
If you select another task type, the corresponding attribute is displayed: