Skip to main content
Version: 1.20.1

REM Use Cases

To take full advantage of the REM functionality, perform some additional actions:

  1. Create a record extended model.
  2. Create necessary attributes and bind them to the model.
    • You can add attributes from the created model using the appropriate related list.
  3. Create a new widget using <rem> or <remform> SimpleTags. The fields added with <rem> tag are usually embedded in an existing form as an additional section, while <remform> is used to create a separate form from the attributes of the record extended model.
  4. Add the created widget to a record form or a portal page.

Use case 1


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:

  1. Create an extension model for this table.

    note

    Save the ID of the model. It will be used in the next steps.

  2. Create attributes.

  3. Create a form widget as described below and save it:

    Template
    <rem modelId="{data.model_id}" tableName="{data.table_name}" recordId = "{data.record_id}" />
    Client script
    (() => {
    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());
    })();
  4. Add this widget to the Task record form.

  5. 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 case 2


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:

  • RE model and its attributes for the User (user) table.
  • REM widget for the User (user) table.
  • REM widget for the Task (task) table.

To do so, complete the following steps:

  1. Create a widget for the User (user) table with the following values:

    FieldValue
    Activetrue
    TablesUser
    Template
    <rem 
    modelId="{data.model_id}"
    tableName="{data.table_name}"
    recordId = "{data.record_id}"
    ></rem>
    Client script
    ( () => {
    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());
    })();
  2. Create a RE model with the attributes you need for the User (user) table.

    note

    Save the ID of the model. It will be used in the next steps.

  3. Add the widget you created in step 1 to the User form.

  4. 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.

  5. Fill in the fields and save the record.

  6. Create a widget for the Task (task) table with the following values:

    FieldValue
    Activetrue
    TablesTask
    Template
    <div>
    <rem
    modelId="{data.model_id}"
    tableName="{data.table_name}"
    recordId = "{data.record_id}"
    readOnly="true"
    ></rem>
    </div>
    Client script
    ( () => {
    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}');

    })();
  7. Add the widget you created in the previous step to the Task form.

As a result, the Task form has read-only values of REM attributes from the User record.

Use case 3


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:

  1. Create the models. Navigate to Record Extended Model → Models. Create four models for the Task (task) table and configure their attributes:

    • Task type. This model has a Reference attribute Specify task type (related_model). This attribute refers to the Models (sys_re_model) table. With this model, you will be able to select one of the models described below on the Task form.
    • Shipment. This model has a String attribute Address.
    • Acceptance. This model has a String attribute Request number.
    • Office cleaning. This model has a String attribute Room number.
  2. Create model client script. Navigate to Record Extended Model → Model Client Scripts and create a script with the attribute values described below.

    • 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.
    ( () => {
    SimpleEventBus.emit('modelChanged', s_form.getValue('related_model'));
    })();
  3. Create widgets. Navigate to Portal Structure → Widgets and create two widgets for the Task table.

    Widget for the model selection

    Template
    <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.

    Client script
    ( () => {
    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

    Template
    <rem 
    modelId="{data.model_id}"
    tableName="{data.table_name}"
    recordId="{data.record_id}"
    ></rem>
    Client script
    ( () => {
    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());
    })();
  4. Create widget instances. Navigate to Portal Structure → Widget Instances and create an instance for each widget created earlier.

    AttributeValue
    WidgetSelect the widget the instance of which you need to create.
    Schema Option Values[]
    OrderSpecify 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.
    Activetrue
  5. Add the widgets for the model selection and displaying that you created earlier to the Task form. Among the form fields, you will see the model selection widget. The widget for displaying the model attributes appears after you select a model:

If you select another task type, the corresponding attribute is displayed: