You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

This class provides methods for operating with the templates.

SimpleTemplate(templateName)


This method instantiates a new SimpleTemplate class object.

NameTypeMandatoryDefault value
templateNameStringNN

Example:

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

applyTo(SimpleRecord)


This method applies the current template to the given object.

When applying a template and inserting a record, remember that the template should match the record form regarding its content and mandatory fields, as the differences with the SimpleRecord table may lead to the server validation failure. As a result, an error message “Current template doesn't match to this record” or a log appear.

Parameter(s):

NameTypeMandatoryDefault value
SimpleRecordSimpleRecordYN

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)


This method applies the value from the Template type field to the object given.

Parameter(s):

NameTypeMandatoryDefault value
SimpleRecordSimpleRecordYN
templateArrayYN

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)


This method creates a new template from a SimpleRecord object with a specified name and returns the ID of the created template.

Parameter(s):

NameTypeMandatoryDefault value
SimpleRecordSimpleRecordYN
templateNameStringYN

Return:

TypeDescription
Big IntegerThe 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)


This method creates a new template out of the “key → value” array with a specified name and a table, which the object template belongs to; in this array, the attribute name is a key, and the key value is a value.

Parameter(s):

NameTypeMandatoryDefault value
templateDataArrayYN
tableNameStringYN
templateNameStringYN
templateTableNameStringNN

Return:

TypeDescription
Big IntegerThe 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)


This method creates a new template with the specified name and a table, which the template object belongs to.

Parameter(s):

NameTypeMandatoryDefault value
templateArrayYN
tableNameStringYN
templateNameStringYN

Return:

TypeDescription
Big IntegerThe 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)


This method gets a template from the template storage by a 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');

  • No labels