Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
This class provides methods for operating with templates.
SimpleTemplate(templateName)
This method instantiates a new SimpleTemplate class object.
Name | Type | Mandatory | Default Value |
---|---|---|---|
templateName | String | N | N |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const Templatetemplate = new SimpleTemplate('incidentStandard task template'); |
applyTo(SimpleRecord)
This method applies the current template to the given object.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
SimpleRecord | SimpleRecord | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
const Incidenttask = new SimpleRecord('itsm_incidenttask'); const Templatetemplate = new SimpleTemplate('incidentStandard task template'); Templatetemplate.applyTo(Incidenttask); ss.info(Incidenttask.getAttributes()); Incidenttask.insert(); |
applyToByTemplateField(SimpleRecord, template)
This method applies the value from the Template type field to the object given.
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:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
const TaskTemplatetemplateRecord = new SimpleRecord('tasksome_template_dict'); TaskTemplatetemplateRecord.get('156837247306928785'); const Tasktask = new SimpleRecord('task'); const Templatetemplate = new SimpleTemplate(); Templatetemplate.applyToByTemplateField(Tasktask, TaskTemplatetemplateRecord.template); ss.info(Tasktask.getAttributes()); Tasktask.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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
SimpleRecord | SimpleRecord | Y | N |
templateName | String | Y | N |
Return:
Type | Description |
---|---|
Big Integer | The template ID. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
const Incidenttask = new SimpleRecord('itsm_incidenttask'); Incidenttask.get('156837247306928785'); const Templatetemplate = new SimpleTemplate(); ss.info(JSON.stringify(Templatetemplate.createBySimpleRecord(Incidenttask, 'newNew incidenttask 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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
templateData | Array | Y | N |
tableName | String | Y | N |
templateName | String | Y | N |
templateTableName | String | N | N |
Return:
Type | Description |
---|---|
Big Integer | The ID of the template created. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
const Templatetemplate = new SimpleTemplate(); ss.info(JSON.stringify(Template.createByTemplateData({'subject': 'New subject'}, 'itsm_incidenttask', 'new incidenttask 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):
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:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
const Templatetemplate = new SimpleTemplate(); ss.info(JSON.stringify(Templatetemplate.createByTemplateField({'subject': 'New subject'}, 'itsm_incidenttask', 'newNew incidenttask template'))); |
get(templateName)
This method gets a template from the template storage by the unique name.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
templateName | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
const Templatetemplate = new SimpleTemplate(); Templatetemplate.get('testRecord template'); |
Table of Contents | ||||
---|---|---|---|---|
|