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

Compare with Current View Page History

« Previous Version 17 Next »

This class provides methods for operating with templates.

SimpleTemplate(templateName)


This method instantiates a new SimpleTemplate class object.

NameTypeMandatoryDefault Value
templateNameStringNN

Example:

SimpleTemplate
const Template = new SimpleTemplate('incident template')



applyTo(SimpleRecord)


This method applies the current template to the given object.


Parameter(s):

NameTypeMandatoryDefault Value
SimpleRecordSimpleRecordYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

applyTo
const Incident = new SimpleRecord('itsm_incident');
const Template = new SimpleTemplate('incident template');
Template.applyTo(Incident);
ss.info(Incident.getAttributes());
Incident.insert();

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 TaskTemplate = new SimpleRecord('task_template');
TaskTemplate.get('156837247306928785');
const Task = new SimpleRecord('task');
const Template = new SimpleTemplate();
Template.applyToByTemplateField(Task, TaskTemplate.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 template created.


Parameter(s):

NameTypeMandatoryDefault Value
SimpleRecordSimpleRecordYN
templateNameStringYN


Return:

TypeDescription
Big IntegerThe template ID.


Example:

createBySimpleRecord
const Incident = new SimpleRecord('itsm_incident');
Incident.get('156837247306928785');
const Template = new SimpleTemplate();
ss.info(JSON.stringify(Template.createBySimpleRecord(Incident, 'new incident 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 to which the object template belongs; 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 template created.


Example:

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

createByTemplateField(template, tableName, templateName)


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


Parameter(s):

NameTypeMandatoryDefault Value
templateArrayYN
tableNameStringYN
templateNameStringYN


Return:

TypeDescription
Big IntegerThe ID of the template created.


Example:

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

get(templateName)


This method gets a template from the template storage by the unique name.


Parameter(s):

NameTypeMandatoryDefault Value
templateNameStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

get
const Template = new SimpleTemplate();
Template.get('test template');

  • No labels