1. Метод get(templateName) – достает шаблон из базы по имени (имя уникальное)
2. Метод applyTo(SimpleRecord) – применяет текущий шаблон к переданному объекту
Пример, создаем новую запись таблицы itsm_incident и применяем к ней шаблон:
let record = new SimpleRecord('itsm_incident');
let template = new SimpleTemplate('incident template');
template.applyTo(record);
ss.info(record.getAttributes());
3. Метод applyToByTemplateField(SimpleRecord, template) – применяет значение из поля типа template к переданному объекту
Пример, представим, что у таблицы тасков есть поле типа template, которое содержит в себе шаблон для тасков, создаем новую запись таблицы тасков и применяем к ней шаблон:
let record = new SimpleRecord('task);
let task = new SimpleRecord(‘task’);
task.get(‘156837247306928785’);
let template = new SimpleTemplate();
template.applyToByTemplateField(record, task.template);
ss.info(record.getAttributes());
6. Метод createByTemplateField(template, tableName, templateName) – создает новый шаблон c заданным именем и таблицей(имя таблицы, которой принадлежит объект шаблона) из значения типа поля шаблон
Пример, представим, что у таблицы тасков есть поле типа template, которое содержит в себе шаблон для тасков, и мы хотим на базе знаяения из этого поля создать полноценный шаблон:
let task = new SimpleRecord(‘task’);
task.get(‘156837247306928785’);
let template = new SimpleTemplate();
ss.info(JSON.stringify(template. createByTemplateField (task.template, ‘task, ‘new task template’)));
applyTo(SimpleRecord)
Method description
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
SimpleRecord | SimpleRecord | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
let record = new SimpleRecord('itsm_incident'); let template = new SimpleTemplate('incident template'); template.applyTo(record); ss.info(record.getAttributes());
applyToByTemplateField(SimpleRecord, template)
Method description
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
SimpleRecord | SimpleRecord | Y | N |
template | Array | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
let record = new SimpleRecord('task); let task = new SimpleRecord(‘task’); task.get(‘156837247306928785’); let template = new SimpleTemplate(); template.applyToByTemplateField(record, task.template); ss.info(record.getAttributes());
createBySimpleRecord(SimpleRecord, templateName)
This method creates a new template from a SimpleRecord object with a specified name and returns the ID of the template created.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
SimpleRecord | SimpleRecord | Y | N |
templateName | String | Y | N |
Return:
Type | Description |
---|---|
Big Integer | The template ID. |
Example:
let record = new SimpleRecord('itsm_incident'); record.get(‘156837247306928785’); let template = new SimpleTemplate(); ss.info(JSON.stringify(template.createBySimpleRecord(record, ‘new incident template’)));
createByTemplateData(templateData, tableName, templateName)
This method creates a new template out of the "key → value" array with a specified name and a table to which the object template belongs; in this array, the attribute name is a key, and the key value is a value.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
templateData | Array | Y | N |
tableName | String | Y | N |
templateName | String | Y | N |
Return:
Type | Description |
---|---|
Big Integer | The ID of the template created. |
Example:
let template = new SimpleTemplate(); ss.info(JSON.stringify(template.createBySimpleRecord({‘subject’: ‘New subject’}, ‘itsm_incident’, ‘new incident template’)));
createByTemplateField(template, tableName, templateName)
Method description
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
template | Array | Y | N |
tableName | String | Y | N |
templateName | String | Y | N |
Return:
Type | Description |
---|---|
Big Integer | The ID of the template created. |
Example:
let template = new SimpleTemplate(); ss.info(JSON.stringify(template.createBySimpleRecord({‘subject’: ‘New subject’}, ‘itsm_incident’, ‘new incident template’)));
get(templateName)
Method description
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
templateName | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
let template = new SimpleTemplate(); template.get('test template');