Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Merged branch "DOC0000262" into parent

This class provides methods for operating with templates.

SimpleTemplate(templateName)


This method instantiates a new SimpleTemplate class object.

NameTypeMandatoryDefault Value
templateNameStringNN

Example:

Code Block
languagejs
themeEclipse
titleSimpleTemplate
linenumberstrue
const template = new SimpleTemplate('Standard task template');



applyTo(SimpleRecord)


This method applies the current template to the given object.

Note

When applying a template and inserting a record, please take into account server validation for the SimpleRecord table.


Parameter(s):

NameTypeMandatoryDefault Value
SimpleRecordSimpleRecordYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleapplyTo

...

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:

Code Block
languagejs
themeEclipse
titleapplyToByTemplateField

...

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:

Code Block
languagejs
themeEclipse
titlecreateBySimpleRecord

...

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 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 created template

...

.


Example:

Code Block
languagejs
themeEclipse
titlecreateByTemplateData

...

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 table to which the template object belongs.


Parameter(s):

NameTypeMandatoryDefault Value
templateArrayYN
tableNameStringYN
templateNameStringYN


Return:

TypeDescription
Big IntegerThe ID of

...

the created template.


Example:

Code Block
languagejs
themeEclipse
title

...

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 the unique name.


Parameter(s):

NameTypeMandatoryDefault Value
templateNameStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleget

...

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

...

Record template');


Table of Contents
absoluteUrltrue
classfixedPosition