Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

What is REM?


To answer this question, we need to provide some theory first.

Thesis 1


In SimpleOne, you can handle with data which is represented as records in tables that have a specified attribute set. Records appear in tables and they have these attribute values given.

Thesis 2


Every table has its own data model stipulated by the business-logic. The data model is represented by the column set (their amount, types, links with another system objects, and so on). This data model can be extended with child table with the same attribute set as a parent one, and an individual attributes inaccessible from the parent table, as an addition.

Attributes extension circuit diagram

Conclusion


To manage the commonalous entities (like ITSM Tasks), we can create a table with appropriate column set and extend from it for Incidents, Change Requests, Problems, and so on, creating respective tables that inherit attributes (columns) from a parent one and besides have their own attributes. For example, attribute overlap in there may be 70%, and unique attributes will be 30% of the total.

In this case, this model works fine (when we do not have many child tables, and the attribute overlap is high). But when the child table number increases, and the attribute overlap decreases, the management of this data model becomes a challenge. Data model with big and complicated table inheritance structure has some disadvantages:

  • It is required to allocate more space for record storage.
  • Scripts are executed slower
  • It is getting harder to configure the functionality related to the specified dictionary, such as data import, layout setting and so one.

A Request Catalog can be taken as an example of such a table (a parent table for the catalog and a record in the table for every request template with specific attributes).

To deal with this issue, another concept has been created and implemented - Record Extended Model.

REM Concept


In this concept, extension concept can be applied for a specified table record giving some featured attributes to it.

Physically, extension model are stored as records of the Models (sys_re_models) table, and they intended to collect specific attributes extending records. Attributes are stored as records of the Attributes (sys_re_attribute) table (extending the Columns (sys_db_column) table).

When a record extension model is applied to a record, it means that an auxiliary record set is created for this record containing information about specific attribute values. So the record has attributes inherited from a table, and in addition, it has attributes sourced from the extension model.

Configuring extension models


Generally, to configure your extension model, you need to:

  1. Create an extension model.
  2. Create attributes (and link it to the model).
  3. (optional) Configure an attribute collection.
  4. Configure RE client script if needed.

Creating models


To create a model, please complete the steps below:

  1. Navigate to Record Extended Model → Models.
  2. Click New and fill in the fields.
  3. Click Save or Save and Exit to apply changes.

Record extended model form fields

FieldMandatoryDescription
NameYThe model name. 
TitleYThe model title. Can be specified in a language other than English.
TableY

Reference to a table affected by the model.

Please note that you cannot specify a read-only table. To use such a table, please turn off this attribute first.

DescriptionNThe model description. 
After insert scriptNSpecify a script that should be executed after a record is created. Develop it using JavaScript extended by the SimpleOne SimpleRecord Server-Side methods.
ActiveNSelect this checkbox to make the model active or inactive.
IconNReduced image intended for the model identification.
Related listsLists
AttributeList of the RE attributes linked to this model.
Model client scriptList of the RE client scripts linked to this model.
Model form elementList of the RE model form element linked to this model.


Note
  1. It is not allowed to create or add an attribute with a name the same for the already created and related to this model.
  2. It is not allowed to rename existing attribute so that a new name becomes the same for the already created and related to this model.

Configuring attributes


To create an attribute, please complete the steps below:

  1. Navigate to Record Extended Model → Attributes.
  2. Click New and fill in the fields.
  3. Click Save or Save and Exit to apply changes.

Attribute form fields

FieldMandatoryDescription
ContainerYReference to a previously created model.
Column TypeYSpecify a column type. 
TitleYAn attribute title. Can be specified in a language other than English. Latin Latin, Cyrillic letters, [0..9] numbers and the underscore symbol ( _ ) are allowed.
Column NameYA column system name. Latin  Latin letters, [0..9] numbers and the underscore symbol ( _ ) are allowed.
Map to ColumnN

Specify a target field to map the attribute value after the record is created. This option allows nimble transferring of the attribute values to fields.


Info

Please note that if the target field is mandatory, then the value is saved before it is processed by server validation engine.

Also, if the target field is mandatory, it should be not displayed on the form, otherwise the client validation engine may hamper the record saving.


CommentsNPut here some comments describing your attribute.
ActiveNSelect this checkbox to make the attribute active or inactive.
Read OnlyNSelect this checkbox to make the field adding by this attribute read-only.
MandatoryNSelect this checkbox to make the field adding by this attribute mandatory.
Full text searchNSelect this checkbox to make the field adding by this attribute indexable.
Display by RefNSelect this checkbox to make the field adding by this attribute display its displayValue instead of a value (see the Display by ref description for more information)
UniqueNSelect this checkbox to make the field adding by this attribute unique.
Type Specification tab
Max LengthN(For the columns that have a String or Text type) Specify  Specify a maximum value length for this column. The value length cannot exceed allowable length for the specified data type.
Default Value tab
Default ValueN

Specify a default value that will be populated to the field when creating a new record. This field may be specified by a JavaScript scenario as well.

Use Dynamic DefaultNSelect this checkbox if you want to generate the default value dynamically.
Dynamic DefaultY

This field appears only when the Use Dynamic Default attribute is set to TRUE checkbox is selected.

Select the script from the Dynamic Default Values (sys_default_value_dynamic) dictionary, so its execution result will be automatically calculated and entered into this field; this value will be the default value for the column specified.

  1. The script must be preliminary created in the Dynamic Default Values (sys_default_value_dynamic) dictionary; otherwise, you will be not able to choose it.
  2. You can choose only active scripts (the the Active attribute is equal to Yes checkbox is selected).


Configuring attribute collections


Attribute collections are implemented for using Many-to-Many Relationships so they allow reusing the same attributes in various models instead of adding them in every model where necessary.

A simplified usage concept is:

  1. Create a collection record as described below
  2. Fill it with previously created attributes or create new ones using the Attributes related list.
  3. Relate this collection with previously created models using the Used in Models related list.

After that, all attributes contained in this collection are used by all models this collection related with.

To create a collection, please complete the steps below:

  1. Navigate to Record Extended Model → Collections.
  2. Click New and fill in the fields.
  3. Click Save or Save and Exit to apply changes.

Collection form field

FieldMandatoryDescription
TitleYSpecify a collection title.
ActiveNSelect this checkbox to make the collection active or inactive.
Related listsLists
AttributesOn this related list, you can create a new attribute related to this collection or select an existing one from dictionary.
Form ElementsOn this related list, you can create a new form element related to this collection or select an existing one from dictionary.
Used in ModelOn this related list, you can create a new model related to this collection or select an existing one from dictionary.
Client ScriptsOn this related list, you can create a new model client script related to this collection or select an existing one from dictionary.


Note
  1. It is not allowed to create or add an attribute with a name similar to the attribute name already created and added to this collection.
  2. It is not allowed to rename an attribute in the collection so that a new name becomes the same as the attribute name already created and added to this collection.
  3. It is not allowed to rename an attribute in the collection so that a new name becomes the same as the attribute name already added or created within the model or within one of the collections linked with the model.
  4. The same collection and model cannot be linked to each other more that once.
  5. Model and collection that have at least one eponymous attribute matching with the model attribute cannot be bound between each other.

Configuring model client scripts


To create a record extended model client script, please complete the steps below:

  1. Navigate to Record Extended Model → Model Client Scripts.
  2. Click New and fill in the fields.
  3. Click Save or Save and Exit to apply changes.

Model client script form fields

FieldMandatoryDescription
NameYClient script name.
TableYReference to a table affected by a model.
RE modelYReference to a previously created model.
TypeY

The script type:

  • onLoad  – it starts when the system displays the form for the first time before users will enter data. Generally, onLoad scripts perform manipulations on the client-side with the current form or set default record values;
  • onChange  – it starts when the specified field in the form is changed;
  • onSubmit  – this client-side script can cancel form submitting by returning returning false;
  • onCellEdit - this client-side script starts at the moment when some cell is to edit.
    • oldvalue - the old value for the cell that was edited;
    • newValue - the new value for the cell that was edited;
    • table - the table name of the cell being edited (for example, sys_db_table); 
    • sysId - the ID of the record relevant to the cell being edited;
    • callback - if this variable is equated to FALSE, then subsequent scripts will not run; otherwise, they will execute.
RE attributeNReference to a previously created model attribute. This field is mandatory.
DescriptionNClient script description.
ActiveNSelect this checkbox to make the script active or inactive.
OrderNClient script execution order. Scripts are executed in ascending order.
ScriptNSpecify a client script. Develop it using JavaScript extended by SimpleOne SimpleForm class.


Configure model form elements


You can arrange the fields of your RE model attributes in a particular order and position, as you can do with form layouts. Group attributes by common features and give them a title. In the screenshot below, a custom model attributes are divided into two columns:

Image Added

Tip

If you want to define a title for a group of attributes organized in one block, use the Begin element.

The title will appear on the relevant page of the Self-Service Portal.

To change the order of displayed attributes, perform the following steps:

  1. Navigate to Record Extended Model → Models.
  2. Open the model you need.
  3. Scroll down to the Related Lists area and open the Model Form Elements tab.
  4. Arrange the attributes by changing value in the Position field. 

    Tip

    Use inline editing: double-click on the cell in the Position field, enter the value and press Enter to save changes. 

    Image Added


To configure a model layout, perform the following steps: 

Anchor
add split elements
add split elements

  1. Navigate to Record Extended Model → Models.
  2. Open the model you need.
  3. Scroll down to the Related Lists area and open the Model Form Elements tab.
  4. Click New and fill in the fields.
  5. Click Save or Save and Exit to add the element.
FieldMandatoryDescription
ContainerYReference to a previously created model. If the element is created from the related list, the field is populated automatically.
PositionYThe order in which the element will be displayed on a form.
Block ElementY

Specify the type of the splitter. Available options:

  • Begin – use this element to define the beginning of block of fields. You can define the name of a group in it. When selected, the Block Title field is displayed.
  • Split – use this element to divide the field into columns.
  • End – use this element to define the end of block of fields.
Block TitleN

Define the title of the group of elements. This title will be displayed above the attributes group on the relevant page of the Self-Service Portal.

Info

This field appears when the Block Element value is Begin.


How to use record extensions


For a full record extension functionality using, some additional actions are to be fulfilled. Below, a simplified implementation procedure can be found.

  1. Create an extension model as described above.
  2. Create necessary attributes and bind them to the model.
    1. You can create attributes out of the your created model using the appropriate related list.
  3. Create a new widget using <rem> or <remform> SimpleTags (based on the widget planned location, a record form or a portal page).
  4. Add newly created widget to a record form using the Form Layout functionality (or add it to the appropriate portal page using the portal pages configuring functionality).

Example of usage


For example, you need to extend your Task table with some attributes allowing to handle some daily duties. To perform this, follow the procedure described above:


Create an extension model for this table.


Create attributes (wonder which fields could be created on this record form within this task). There should be a single attribute for every single for field.


Create a form widget as described below and save it:

Code Block
languagexml
themeEclipse
titleWidget Template
<rem modelId="{data.model_id}" tableName="{data.table_name}" recordId = "{data.record_id}" />


Code Block
languagejs
themeEclipse
titleWidget Client Script
linenumberstrue
(() => {
  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());
})();


Add this widget to the record form view using the Form Layout functionality:


Navigate to a record form using the URL looking like: https://instance.example.com/record/task?model_id=XXXXXXXXXXXXXXXXX

Info

In this URL. you need to substitute the X's with the model ID you are using in this case. To know it, please complete the steps below:

  1. Navigate to Record Extended Model → Models.
  2. The model ID can be found in the ID column of the list displayed (if this column is absent, then let it display using the List layout functionality).

Without using this URL addition, a non-extended form is displayed.

After that, a form containing fields defined by attributes bound to the model specified is displayed.

Table of Contents
absoluteUrltrue
classfixedPosition