Skip to main content
Version: 1.23.3

SimpleTemplate

This class provides methods that operate with the templates.

SimpleTemplate(templateName)


Use this constructor to instantiate a new object of the SimpleTemplate class.

Parameter(s):

NameTypeMandatoryDefault value
templateNameStringNN

Example:

SimpleTemplate()
const template = new SimpleTemplate('Standard task template');

applyTo(SimpleRecord)


Use this method to apply the current template to the given object.

caution

When applying a template and inserting a record, remember that the template should match the form of the record in terms of content and mandatory fields, as differences with the SimpleRecord table can cause the server validation to fail. As a result, an error message Current template doesn't match to this record or a log appears.

Parameter(s):

NameTypeMandatoryDefault value
SimpleRecordSimpleRecord objectYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

applyTo()
const task = new SimpleRecord('task');
const template = new SimpleTemplate('Standard task template');
template.applyTo(task);
task.subject = 'From template Task';
ss.info('Created Task ID: ' + task.insert());
ss.info(task.getErrors());
// Info: Created Task ID: 163777658710999477
// Info: []

applyToByTemplateField(SimpleRecord, template)


Use this method to apply the value from the Template type field to the object given.

Parameter(s):

NameTypeMandatoryDefault value
SimpleRecordSimpleRecord objectYN
templateArray/StringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

applyToByTemplateField()
const templateRecord = new SimpleRecord('some_template_dict');
templateRecord.get('156837247306928785');
const task = new SimpleRecord('task');
const template = new SimpleTemplate();
template.applyToByTemplateField(task, templateRecord.template);
ss.info(task.getAttributes());
task.insert();

createBySimpleRecord(SimpleRecord, templateName)


Use this method to create a template from a SimpleRecord object with a specified name. The method returns the ID of the created template.

Parameter(s):

NameTypeMandatoryDefault value
SimpleRecordSimpleRecord objectYN
templateNameStringYN
templateTableNameStringN''

Return:

TypeDescription
StringThis method returns the template ID.

Example:

createBySimpleRecord()
const task = new SimpleRecord('task');
task.get('156837247306928785');
const template = new SimpleTemplate();
ss.info(JSON.stringify(template.createBySimpleRecord(task, 'New task template')));

createByTemplateData(templateData, tableName, templateName, templateTableName)


Use this method to create a template. To do so, specify the name and table to which the object template belongs. The attribute name of the templateData object is the system name of the column.

Parameter(s):

NameTypeMandatoryDefault value
templateDataObjectYN
tableNameStringYN
templateNameStringYN
templateTableNameStringN''

Return:

TypeDescription
StringThis method returns the ID of the created template.

Example:

createByTemplateData()
const template = new SimpleTemplate();
ss.info(JSON.stringify(template.createByTemplateData({'subject': 'New subject'}, 'task', 'new task template')));

createByTemplateField(template, tableName, templateName)


Use this method to create a template with the specified name and a table to which the template object belongs.

Parameter(s):

NameTypeMandatoryDefault value
templateObjectYN
tableNameStringYN
templateNameStringYN
templateTableNameStringN''

Return:

TypeDescription
StringThis method returns the ID of the created template.

Example:

createByTemplateField()
const template = new SimpleTemplate();
ss.info(JSON.stringify(template.createByTemplateField({'subject': 'New subject'}, 'task', 'New task template')));

get(templateName)


Use this method to get a template from the template storage by its unique name.

Parameter(s):

NameTypeMandatoryDefault value
templateNameStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

get()
const template = new SimpleTemplate();
template.get('Record template');