Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This server class provides methods to operate database records.

SimpleRecord(tableName)


This method instantiates a SimpleRecord class object for a particular table.


Parameter(s):

NameTypeMandatoryDefault Value
tableNameStringYN

Example:

Code Block
languagejs
themeEclipse
titleSimpleRecord
linenumberstrue
const taskRecord = new SimpleRecord('task');


REM attribute object


The SimpleRecord class has a special object for Record Extended Modelsrem_attr – containing information about the REM attributes. It is used to read and define edit REM attributes values of the current record with other class methods as in the example below.

Tip

rem_attr has a number of methods equal to methods of the SimpleRecord: 

For example:

record.rem_attr.getValue('my_rem_attribute');

Parameter:

NameTypeMandatoryDefault Value
propertyStringYN

Return:

TypeDescription
SimpleRecord objectThis method returns the SimpleRecord object from the defined RE model.
The method returns null if the record does not have a RE model.

Example:

Code Block
languagejs
themeEclipse
titleget using REM
linenumberstrue
const record = new SimpleRecord('task');
record.get('160638931615274614'); // Example record ID supposing to be extended with RE attributes 
// record.rem_attr - an object containing information about RE attributes

if (record.getReModelId()) {
    ss.info(record.rem_attr.description); // Here, we have called the RE attribute as a property
}

addOrCondition(property, operator, value)


This method appends a 2-or-3 parameter OR condition to an existing query. It works in conjunction with any of the addQuery() methods. In this method, you can use any preferred operator from the Condition Operators list, specified either in lowercase or in uppercase. Please notice Notice that you need to use the system name of the operator in your scripts.

Parameter(s):

You can also specify a RE model attribute of a specific table. To filter records, use the operators corresponding to the attribute type.

Note

The condition may contain criteria based on the attribute of different RE models. If such criteria are built using the AND operator, the selection of records will be empty. To return records that match a condition, use the OR operator.


Parameter(s):

NameTypeMandatoryDefault Value
propertyStringY

N

operatorString (refer to the Condition Operators article for more information
Info

For the REM attributes use the following pattern:

'<sys_id>:<attr_name>' 

where sys_id – the ID of the model that contain the attribute, and attr_name – the system name of the REM attribute.


operatorString (refer to the Condition Operators article for more information)NN
valueInteger
or
, String
or
, Boolean, Array or
Array
SimpleRecord objectYN


Return:

TypeDescription
SimpleRecordThe query containing OR condition added to the SimpleRecord object.


ExampleExamples:

Code Block
languagejs
themeEclipse
titleaddOrCondition
linenumberstrue
const record = new SimpleRecord('task');
record.addQuery('subject', 'like', 'not work')
record.addOrCondition('description', 'like', 'not work');
ss.info('Condition query: ' + record.getConditionQuery());
record.query();
// Info: Condition query: (subjectLIKEnot work)^OR(descriptionLIKEnot work)

addQuery(property, operator, value)

This method adds a condition to make a selection of records from the database. In this method, you can use any preferred operator from the Condition Operators list, specified either in lowercase or in uppercase. Please notice that you need to use system name of the operator in your scripts.

Parameter(s):

NameTypeMandatoryDefault ValuepropertyStringYNoperatorString (refer to the Condition Operators article for more information)NNvalueInteger or String or Boolean or ArrayYN

Return:

TypeDescriptionSimpleRecordThe query condition added to the SimpleRecord object.


Code Block
languagejs
themeEclipse
titleaddOrCondition with REM attribute
linenumberstrue
let record = new SimpleRecord('task');
record.addQuery('

Example:

Code Block
languagejs
themeEclipse
titleaddQuery
linenumberstrue
const task = new SimpleRecord('task');
task.addQuery('active', true);
task.addQuery('subject', 'like', 'emailnot work');
taskrecord.addQueryaddOrCondition('sys_created_at166972638116358001:description', '<contains', '2019-04-01 00:00:00not work');
task.query();
ss.info('CountCondition query: ' + taskrecord.getRowCountgetConditionQuery());
record.query();
// Info: Condition Countquery: 0

addEncodedQuery(condition)

This method adds encoded query and applies it to the current query method.

Info

Decoded query is also applicable.

Parameter(s):

NameTypeMandatoryDefault ValueconditionString YN

Return:

TypeDescriptionVoidThis method does not return a value.
 (subjectLIKEnot work)^OR(166972638116358001:descriptionLIKEnot work)


Info

It is possible to pass the SimpleRecord object as current.{reference_field_name} instead of the record ID as the addOrCondition() method value. The script example

ExampleaddEncodedQuery

:

Code Block
languagejs
themeEclipse
title
Passing SimpleRecord as an argument
linenumberstrue
collapsetrue
const 
currentUser
task = 
ss.getUser(); const reciever =
new SimpleRecord('
employee
task');
reciever
task.
addQuery('active', true
setLimit(1);
task.query();
if (
currentUser.company.class === 'internal'
!task.next()) {
  
reciever.addEncodedQuery(`(company=${currentUser.getValue('company')})`
ss.info('No tasks found!');
}
 
else
 
{
return;
}

const relatedTask = new 
reciever.addEncodedQuery(`%28sys_db_table_id%3D158645243815904649%5Esys_created_byDYNAMIC156957117519820256%29`
SimpleRecord('task');
} ss
relatedTask.
info('Decoded condition
addQuery('caller', task.caller);
relatedTask.addOrCondition('assigned_user', task.caller);
relatedTask.query();
ss.info('Tasks count: ' + 
reciever
relatedTask.
getConditionQuery
getRowCount(
)
)
; reciever.query(
);
// Info: 
Decoded
Tasks 
condition: (active=1)^((sys_db_table_id=158645243815904649^sys_created_byDYNAMIC156957117519820256))

canCreate()

This method checks whether inserting new records in this table satisfies the Access Control Rule (ACL).

Also, you can use this method in your UI Actions to adjust its visibility more precisely.

Return:

TypeDescriptionBooleanThe method returns 'true' if this operation is permitted; otherwise, it returns 'false'.
count: 122



addQuery(property, operator, value)


This method adds a condition to make a selection of records from the database. In this method, you can use any preferred operator from the Condition Operators list, specified either in lowercase or in uppercase. Note that you need to use system name of the operator in your scripts.

You can also specify a RE model attribute of a specific table. To filter records, use the operators corresponding to the attribute type. 

Note

The condition may contain criteria based on the attribute of different RE models. If such criteria are built using the AND operator, the selection of records will be empty. To return records that match a condition, use the OR operator.

Parameter(s):

NameTypeMandatoryDefault Value
propertyStringY

N

Info

For the REM attributes use the following pattern:

'<sys_id>:<attr_name>'

where sys_id – the ID of the model that contain the attribute, and attr_name – the system name of the REM attribute.


operatorString (refer to the Condition Operators article for more information)NN
valueInteger or String or Boolean or Array or SimpleRecord objectYN


Return:

TypeDescription
SimpleRecordThe query condition added to the SimpleRecord object.


Examples:

Example:

Code Block
languagejs
themeEclipse
titlecanCreate
linenumberstrue
current.canCreate();

canDelete()

This method checks whether deleting records in this table satisfies the Access Control Rule (ACL).

Also, you can use this method in your UI Actions to adjust its visibility more precisely.

Return:

TypeDescriptionBooleanThe method returns 'true' if this operation is permitted; otherwise, it returns 'false'.

Example:

Example:
Code Block
languagejs
themeEclipse
titlecanDeleteaddQuery
linenumberstrue
current.canDelete();

canRead()

This method checks whether reading records in this table satisfies the Access Control Rule (ACL).

Also, you can use this method in your UI Actions to adjust its visibility more precisely.

Return:

TypeDescriptionBooleanThe method returns 'true' if this operation is permitted; otherwise, it returns 'false'.
const task = new SimpleRecord('task');
task.addQuery('active', true);
task.addQuery('subject', 'like', 'email');
task.addQuery('sys_created_at', '<', '2019-04-01 00:00:00');
task.query();
ss.info('Count: ' + task.getRowCount());
// Info: Count: 0


Code Block
languagejs
themeEclipse
titlecanReadaddQuery with REM attribute
linenumberstrue
current.canRead();

canUpdate()

This method checks whether updating records in this table satisfies the Access Control Rule (ACL).

Also, you can use this method in your UI Actions to adjust its visibility more precisely.

Return:

TypeDescriptionBooleanThe method returns 'true' if this operation is permitted; otherwise, it returns 'false'.
let record = new SimpleRecord('task');
record.addQuery('166972638116358001:description', 'not work');
record.query();
ss.info("Total rows: " + record.getRowCount());
// Info: Total rows: 1


Info

It is possible to pass the SimpleRecord object as current.{reference_field_name} instead of the record ID as the method addQuery() value. The script example

Example

Example:

canUpdate
Code Block
languagejs
themeEclipse
titledeleteMultiple
linenumberstrue

:

Code Block
languagejs
themeEclipse
title
const record
Passing SimpleRecord as an argument
linenumberstrue
collapsetrue
current.canUpdate();

deleteMultiple()

This method allows deleting multiple records in a query selection. Please note that attachments cannot be deleted using this method.

Note

Do not use this method on tables with dependencies. Always delete each record individually.

Return:

TypeDescriptionBooleanThis method returns 'true' if records are deleted successfully; otherwise, it returns 'false'.
const task = new SimpleRecord('task');
task.setLimit(1);
task.query();
if (!task.next()) {
  ss.info('No tasks found!');
  return;
}

const otherTask = new SimpleRecord
('sys_activity_feed_item'
('task');
otherTask.addQuery('caller', task.caller);
record
otherTask.addQuery('
content
sys_id', '
isempty'
!=', task.sys_id);
record
otherTask.query();
ss.info(
record
'Tasks count: ' + otherTask.getRowCount());
// Info:
0
deleteRecord(
 Tasks count: 720



addEncodedQuery(condition)


This method deletes the current record.

Return:

TypeDescriptionBooleanThis method returns 'true' if the record is deleted successfully; otherwise it returns 'false'.

adds encoded query and applies it to the current query method.

Info

Decoded query is also applicable.

You can also specify a RE model attribute of a specific table. To filter records, use the operators corresponding to the attribute type. 

Note

The condition may contain criteria based on the attribute of different RE models. If such criteria are built using the AND operator, the selection of records will be empty. To return records that match a condition, use the OR operator.

Use curly brackets when setting a filter argument for the text fields of type String, Text, Translated Text, Conditions, and URL. Using parenthesis for the argument may cause a filter query error.

Code Block
languagejava
themeEclipse
titleFilter with text fields
linenumberstrue
collapsetrue
const subject = 'Hello, SimpleOne)';
const task = new

Example:

Code Block
languagejs
themeEclipse
titledeleteRecord
linenumberstrue
const task = new SimpleRecord('task');
task.get('155931135900000000'addEncodedQuery(`subjectLIKE${subject}`);
const isDeleted = ss.info(task.deleteRecordgetConditionQuery());
iftry (isDeleted) {
    sstask.info('Task with ID ' + task.sys_id + ' was deleted!'query();
} catch else(e) {
    ss.error('Errors: ' + task.getErrors());
}

get(propertyOrValue, value)

This method loads an object from a database by the field value, or, in a specific case, by the sys_id.
e.message);
} 
// Info: (subjectLIKEHello, SimpleOne))
// Error: Condition query is invalid

Parameter(s):

NameTypeMandatoryDefault Value
propertyOrValue

String value of record ID or property name. If it is equal to the property name, then the second parameter 'value' is mandatory.

Note

Passing 'NULL' or an empty string as the propertyOrValue parameter value will cause an exception looking alike:

"Argument 1 passed to "get()" must not be empty".

YNvalueStringNNULL
conditionString Y

N

Info

For the REM attributes use the following pattern:

'<sys_id>%3A<attr_name>'

where sys_id – the ID of the model that contain the attribute, and attr_name – the system name of the REM attribute.



Return:

TypeDescription
SimpleRecord object
VoidThis method
returns the SimpleRecord object from the table specified in the query.
Example
does not return a value.


Examples:

Code Block
languagejs
themeEclipse
titlegetaddEncodedQuery
linenumberstrue
const current currentUser = ss.getUser();
const receiver = new SimpleRecord('taskemployee');
currentreceiver.getaddQuery('163663310116371174active', true);

if (current.sys_idcurrentUser.company.class === 'internal') {
    const company = new SimpleRecord('org_company'receiver.addEncodedQuery(`(company=${currentUser.getValue('company')})`);
} else {
   company receiver.get('c_website', current.c_customer_url);
    ss.eventQueue('notify.responsible', current, company.responsible.email);
}

getAttributes()

This method returns an object with current record properties as keys and properties values as key values.

Return:

TypeDescriptionObjectThe array containing attributes.
addEncodedQuery(`%28sys_db_table_id%3D158645243815904649%5Esys_created_byDYNAMIC156957117519820256%29`);
}
ss.info('Decoded condition: ' + receiver.getConditionQuery());
receiver.query();
// Info: Decoded condition: (active=1)^((sys_db_table_id=158645243815904649^sys_created_byDYNAMIC156957117519820256))


Code Block
languagejs
Code Block
languagejs
themeEclipse
titlegetAttributesaddEncodedQuery with REM attributes
linenumberstrue
const userRecordreceier = ss.getUser( new SimpleRecord('task');
receiver.addQuery('active', true);
receiver.addEncodedQuery('%28sys_db_table_id%3D158645243815904649%5E166972638116358001%3AdescriptionLIKEwork`);
ss.info(userRecord.getAttributes'Decoded condition: ' + receiver.getConditionQuery());
/receiver.query();
// Info: {"sys_id":"155931135900000001","sys_created_at":"2019-09-30 00:00:00","sys_updated_at":"2021-06-28...
getClassDisplayValue
 Decoded condition: (active=1)^((sys_db_table_id=158645243815904649^166972638116358001:descriptionLIKEwork))

canCreate()


This method returns the table title. If the title is not set, then returns namechecks whether inserting new records in this table satisfies the Access Control Rule (ACL).

Also, you can use this method in your UI Actions to adjust its visibility more precisely.


Return:

TypeDescription
StringTitle or name
BooleanThe method returns 'true' if this operation is permitted; otherwise, it returns 'false'.


Example:

Code Block
languagejs
themeEclipse
titlegetClassDisplayValuecanCreate
linenumberstrue
const current = new SimpleRecord('task');
current.getcanCreate('163663310116371174');
ss.info(current.getClassDisplayValue());
// Info: Task
getConditionQuery

canDelete()


This method

returns current query condition

checks whether deleting records in this table satisfies the Access Control Rule (ACL).

Also, you can use this method in your UI Actions to adjust its visibility more precisely.


Return:

TypeDescription
StringThe query condition
BooleanThe method returns 'true' if this operation is permitted; otherwise, it returns 'false'.


Example:

Code Block
languagejs
themeEclipse
titlegetConditionQuerycanDelete
linenumberstrue
const task = new SimpleRecord('task');
const condition = task.addQuery('state', '7');
condition.addOrCondition('priority', '<', '3');
ss.info('Condition before query: ' + task.getConditionQuery());
task.query();
ss.info('Condition after query: ' + task.getConditionQuery());
// Info: Condition before query: (state=7)^OR(priority<3)
// Info: Condition after query:
getDisplayValue(property)  AnchorgetDisplayValue()getDisplayValue()

This method returns the value of display_by_ref field or record value. For example, for the reference field the entity name will be returned, but not the ID.

Parameter(s):

NameTypeMandatoryDefault ValuePropertyStringNNULL

Return:

TypeDescriptionStringA field or record value.
current.canDelete();

canRead()


This method checks whether reading records in this table satisfies the Access Control Rule (ACL).

Also, you can use this method in your UI Actions to adjust its visibility more precisely.


Return:

TypeDescription
BooleanThe method returns 'true' if this operation is permitted; otherwise, it returns 'false'.


Example:

Code Block
languagejs
themeEclipse
titlecanRead
linenumberstrue
current.canRead();


canUpdate()


This method checks whether updating records in this table satisfies the Access Control Rule (ACL).

Also, you can use this method in your UI Actions to adjust its visibility more precisely.


Return:

TypeDescription
BooleanThe method returns 'true' if this operation is permitted; otherwise, it returns 'false'.


Example:

Code Block
languagejs
themeEclipse
titlecanUpdate
linenumberstrue
current.canUpdate();

deleteMultiple()


This method allows deleting multiple records in a query selection. Please note that attachments cannot be deleted using this method.

Note

Do not use this method on tables with dependencies. Always delete each record individually.


Return:

TypeDescription
BooleanThis method returns 'true' if records are deleted successfully; otherwise, it returns 'false'.


Example:

Code Block
languagejs
themeEclipse
titledeleteMultiple

Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValue
linenumberstrue
const currentrecord = new SimpleRecord('tasksys_activity_feed_item');
currentrecord.getaddQuery('163663310116371174''content', 'isempty');
record.query();
ss.info(currentrecord.getDisplayValuegetRowCount('caller'));
ss.info(currentrecord.getValuedeleteMultiple('caller'));
// Info: John Doe0
// Info: 155931135900000001true
getErrors


deleteRecord()

  AnchorgetErrors()getErrors()

If the record creating, updating or deleting fails, then this method will display an error message.

Use this method for control purposes if there any validation errors within your scripts.

Warning

Some validation errors may not be displayed within the debug process, so it is highly recommended to use this method.

For example, errors in condition queries passed by methods like addEncodedQuery(condition) or similar methods can be displayed by calling this method.

Return:

TypeDescriptionArrayThe error value.


This method deletes the current record.


Return:

TypeDescription
BooleanThis method returns 'true' if the record is deleted successfully; otherwise it returns 'false'.


Example:

Code Block
languagejs
themeEclipse
titledeleteRecord

Example:

Code Block
languagejs
themeEclipse
titlegetErrors
linenumberstrue
const recordtask = new SimpleRecord('task');
task.get('user155931135900000000');
if (!task.sys_id) {
  return;
}
const insertedRecordIdisDeleted = recordtask.insertdeleteRecord();
if (insertedRecordId == 0isDeleted) {
  ss.info(record.getErrors());
}
// Info: ["The \"\"First Name\" [first_name]\" field is mandatory. (record id: )",...
getLabel(property)  AnchorgetLabel()getLabel()

This method gets the field title.

Info The getLabel() method cannot be used with REM attributes. Instead, use the getTitle() method
'Task with ID ' + task.sys_id + ' was deleted!');
  return;
}
ss.error(task.getErrors());


get(propertyOrValue, value)


This method loads an object from a database by the field value, or, in a specific case, by the sys_id.


Parameter(s):

NameTypeMandatoryDefault Value
propertyStringYN

Return:

TypeDescriptionStringThe field name.
propertyOrValue

String value of record ID or property name. If it is equal to the property name, then the second parameter 'value' is mandatory.

Note

Passing 'NULL' or an empty string as the propertyOrValue parameter value causes an exception:

"Argument 1 passed to "get()" must not be empty".


YN
valueString or SimpleRecord objectNNULL


Return:

TypeDescription
SimpleRecord objectThis method returns a SimpleRecord object from the table specified in the query.


Example:

Example:

Code Block
languagejs
themeEclipse
titlegetLabelget
linenumberstrue
const currenttask = ss.getUser();
const fieldLabel = current.getLabel('usernamenew SimpleRecord('task');
sstask.addErrorMessageget('Field "163663310116371174' +  fieldLabel + '" cannot be blank');
// Field "Login" cannot be blank

getReModelId()

This method retrieves the ID of the RE model related to the current record. To set a new model ID use the setReModelId method.

Return:

TypeDescription

String

The method returns the ID of the model. If model is not found, the method returns null.
); // get by ID

if (task.state == '18') { // Rejected
  const company = new SimpleRecord('org_company');
  company.get('c_website', task.c_customer_url); // get by Customer URL
  ss.eventQueue('notify.responsible', task, company.responsible.email);
}


Info

It is possible to pass the SimpleRecord object as current.{reference_field_name} instead of the record ID as the get() method value. The script example

ExamplegetReModelId

:

Code Block
languagejs
themeEclipse
title
Passing SimpleRecord as an argument
linenumberstrue
collapsetrue
(function executeRule(current, previous
const task = 
null /*not null only when action is update*/) { if (current.getReModelId
new SimpleRecord('task');
task.setLimit(1);
task.query();
if (!task.next()) {
  ss.info('No tasks found!');
  
return;
}

const 
model
user = new SimpleRecord('
sys_rmc_model'
user');
model
user.get(
current
task.
getReModelId()
caller);
// current model current.$$service

user.language_id = 
model.getValue('cmdb_service_id')
'156628684306541141'; // 
pass service if field exists } })(current, previous);

getRowCount()

This method gets the amount of items in a row.

English
ss.info(user.update());
// Info: 167515292501757147



getAttributes()


This method returns an object with current record properties as keys and properties values as key values.


ReturnReturns:

TypeDescription
IntegerItems amount in a row specified.

Example:

ObjectThe array containing attributes.


Code Block
languagejs
themeEclipse
titlegetRowCountgetAttributes
linenumberstrue
const taskuserRecord = new SimpleRecord('task');
task.queryss.getUser();
ss.addInfoMessage('All Tasks Count: ' + task.getRowCountinfo(userRecord.getAttributes());
// All Tasks Count: 2

getTableName()

This method gets the current table
Info: {"sys_id":"155931135900000001","sys_created_at":"2019-09-30 00:00:00","sys_updated_at":"2021-06-28...

getClassDisplayValue()


This method returns the table title. If the title is not set, then returns name.


Return:

TypeDescription
String
The current table
Title or name.


Example:

Code Block
languagejs
themeEclipse
titlegetTableNamegetClassDisplayValue
linenumberstrue
const current = ss.getUser(new SimpleRecord('task');
current.get('163663310116371174');
ss.info('/list/' + current.getTableNamegetClassDisplayValue() + '/' + current.sys_id);
// Info: /list/user/155931135900000001
getTitle(attribute) 
Task

getConditionQuery

AnchorgetTitle

()

getTitle()

This method returns

the title of the defined RE attribute.

Parameter:

NameTypeMandatoryDefault ValuecolumnStringYN

current query condition.


Return:

TypeDescription
String
This method returns the title of the attribute
The query condition.


Example:

Code Block
languagejs
themeEclipse
titlegetTitlegetConditionQuery
linenumberstrue
const currenttask = new SimpleRecord('task');
current.getconst condition = task.addQuery('163638951512716126state', '7');
if (current.sys_id) {
    ss.info(current.rem_attr.getTitle('reviewed'));
}condition.addOrCondition('priority', '<', '3');
ss.info('Condition before query: ' + task.getConditionQuery());
task.query();
ss.info('Condition after query: ' + task.getConditionQuery());
// Info: Review completed
Info

To return column titles which are not part of REM, use the getLabel() method.

getValue
Condition before query: (state=7)^OR(priority<3)
// Info: Condition after query:

getDisplayValue(property) 
Anchor

getValue

getDisplayValue()

getValue

getDisplayValue()


This method returns the value of

the object property based on its name.

display_by_ref field or record value. For example, for the reference field the entity name will be returned, but not the ID.


Parameter(s):

If the field is of the Reference or List types, then its sys_id value returns.

Note

To speed up the script execution, use this method to get values of the fields of the Reference type instead of Dot-walking.

As an example, it is preferable to use the current.getValue('reference_field') structure instead of current.reference_field.sys_id one.

Parameter(s):

Name
Name
TypeMandatoryDefault Value
property
PropertyString
Y
N
N
NULL


Return:

TypeDescription
Mixed

The string value of the object property.

StringA field or record value.


Example:

Code Block
languagejs
themeEclipse
titlegetValuegetDisplayValue
linenumberstrue
const current = ss.getUser(new SimpleRecord('task');
const user = new SimpleRecordcurrent.get('user163663310116371174');
userss.addQuery('timezone_id', info(current.getValuegetDisplayValue('timezone_idcaller'));
user.query();
ss.info('Same timezone for: ' + user.getRowCount() + ' users'current.getValue('caller'));
// Info: Same timezone for: 36 users

hasAttachment()

This method checks whether the record specified has an attachment or not
John Doe
// Info: 155931135900000001

getErrors() 
Anchor
getErrors
getErrors


If the record creating, updating or deleting fails, then this method will display an error message.

Use this method for control purposes if there any validation errors within your scripts.

Warning

Some validation errors may not be displayed within the debug process, so it is highly recommended to use this method.

For example, errors in condition queries passed by methods like addEncodedQuery(condition) or similar methods can be displayed by calling this method.


Return:

TypeDescription
BooleanMethod returns 'true' if the record has an attachment; otherwise, it returns 'false'
ArrayThe error value.


Example:

Code Block
languagejs
themeEclipse
titlehasAttachmentgetErrors
linenumberstrue
const currentrecord = new SimpleRecord('taskuser');
current.get('163663310116371174');
const hasAttachinsertedRecordId = currentrecord.hasAttachmentinsert();
if (!hasAttachinsertedRecordId == 0) {
  ss.info(record.addErrorMessage('File should be attached');
  returngetErrors());
}
current.state = '2'; // Open
current.update();

initialize()

This method populates all active empty fields with their predefined default values.

It works only for new records that were never saved and cannot be called repeatedly.

This method is called automatically and implicitly at the first set operation (also known as "the setter").
// Info: ["The \"\"First Name\" [first_name]\" field is mandatory. (record id: )",...


getLabel(property) 
Anchor
getLabel()
getLabel()


This method gets the field title.

Info

 The getLabel() method cannot be used with REM attributes. Instead, use the getTitle() method.


Parameter(s):

NameTypeMandatoryDefault Value
propertyStringYN


Return:

TypeDescription
VoidThis method does not return a value
StringThe field name.


Example:

Code Block
languagejs
themeEclipse
titleinitializegetLabel
linenumberstrue
const taskRecordcurrent = new SimpleRecord('task');
ss.info(taskRecord.getAttributesgetUser().caller);
taskRecord.initialize(const fieldLabel = current.getLabel('username');
ss.info(taskRecord.getAttributes().calleraddErrorMessage('Field "' +  fieldLabel + '" cannot be blank');
// Info: 
// Info: 155931135900000001

insert()

This method uses the field values of the current record to insert a new one.

If the record is not inserted then method returns '0' (zero) and adds an informative error message which can be obtained with getErrors() method.

Return:

 Field "Login" cannot be blank

getReModelId() 
Anchor
getremodelid
getremodelid


This method retrieves the ID of the RE model related to the current record. To set a new model ID use the setReModelId method.

Return:

TypeDescription

String

The method returns the ID of the model. If model is not found, the method returns null
TypeDescriptionInteger
  • If record was not inserted, then method returns '0' and you can get a message containing list of errors.
  • As a normal case, a unique ID of the inserted record returns
    .

    Example:

    Code Block
    languagejs
    themeEclipse
    titleinsertgetReModelId
    linenumberstrue
    const newTask(function executeRule(current, previous = new SimpleRecord('task');
    newTask.subject = 'Subtask';
    const inserterTaskID = newTask.insert();
    ss.info(`/record/task/${inserterTaskID}`);
    // Info: /record/task/163675231910113745

    isTableVcsEnabled()

    This method checks whether the VCS enabled attribute is enabled against the specified table or not. 

    Return
    null /*not null only when action is update*/) {
        if (current.getReModelId()) {
            const model = new SimpleRecord('sys_rmc_model');
            model.get(current.getReModelId()); // current model
            current.$$service = model.getValue('cmdb_service_id'); // pass service if field exists
        }
    })(current, previous);


    getRowCount()


    This method gets the amount of items in a row.


    Returns:

    TypeDescription
    BooleanThis method returns the value of the is_vcs_enabled
    IntegerItems amount in a row specified
    attribute of record table
    .

    Example:

    Code Block
    languagejs
    themeEclipse
    titleisTableVcsEnabledgetRowCount
    linenumberstrue
    const tabletask = new SimpleRecord('sys_db_tabletask');
    task.query();
    ss.info(table.isTableVcsEnabledaddInfoMessage('All Tasks Count: ' + task.getRowCount());
    // All Tasks InfoCount: true2
    matchesCondition


    getTableName(

    condition

    )


    This method

    checks whether

    gets the current

    record meets the condition in the current state

    table name.

    Name


    Return:

    Type
    MandatoryDefault Valuecondition
    Description
    String
    N''
    Return
    The current table name.


    Example:

    Type
    Code Block
    DescriptionBooleanThis method returns 'true' if the record meets the condition specified; otherwise; it returns 'false'.
    language
    Code Block
    languagejs
    themeEclipse
    titlematchesConditiongetTableName
    linenumberstrue
    const taskcurrent = new SimpleRecord('task');
    task.description = 'emaio'ss.getUser();
    ss.info(task.matchesCondition('descriptionLIKEemail')); // false
    task.description = 'email';
    ss.info(task.matchesCondition('descriptionLIKEemail')); // true
    next
    /list/' + current.getTableName() + '/' + current.sys_id);
    // Info: /list/user/155931135900000001

    getTitle(attribute) 
    Anchor
    getTitle()
    getTitle()


    This method returns the next record in the query. If this is the first call, this method returns the first record in query. If the query is empty, this method returns 'false'.

    Return:

    TypeRecord or Boolean

    title of the defined RE attribute.

    Parameter:

    NameTypeMandatoryDefault Value
    columnStringYN

    Return:

    TypeDescription
    StringThis method returns the title of the attribute.


    Example:

    Code Block
    languagejs
    themeEclipse
    titlegetTitle

    Example:

    Until the method is called, the values of a SimpleRecord object are not available, and the 'Current record is not set' message will occur. Consider the example:

    Code Block
    languagejs
    themeEclipse
    titlenext
    linenumberstrue
    const usercurrent = new SimpleRecord('usertask');
    usercurrent.setLimitget(1'163638951512716126');
    user.query();
    user.next();
    if (current.sys_id) {
        ss.info(usercurrent.sys_idrem_attr.getTitle('reviewed'));
    }
    // Info: 100000000000000000Review completed
    Note
    Code Block
    languagejs
    themeEclipse
    const task = new SimpleRecord('task');
    task.setLimit(1);
    task.query();
    // task.next();
    ss.info(task.number);
    // Error: Current record is not set.

    orderBy(column)

    This method sorts records in the ascending order.

    Tip

    Call this method several times to order by multiple columns.


    Info

    To return column titles which are not part of REM, use the getLabel() method.

    getValue(property) 
    Anchor
    getValue()
    getValue()


    This method returns the value of the object property based on its name.

    If the field is of the Reference or List types, then its sys_id value returns.

    Note

    To speed up the script execution, use this method to get values of the fields of the Reference type instead of Dot-walking.

    As an example, it is preferable to use the current.getValue('reference_field') structure instead of current.reference_field.sys_id one.


    Parameter(Parameter(s):

    NameTypeMandatoryDefault Value
    column
    propertyStringYN


    Return:

    TypeDescription
    VoidThis method does not return a value.
    Example:
    Mixed

    The string value of the object property.


    Code Block
    languagejs
    themeEclipse
    titleorderBygetValue
    linenumberstrue
    const current = ss.getUser();
    const firstLoguser = new SimpleRecord('sys_loguser');
    firstLoguser.orderByaddQuery('sys_created_at'); // oldest record first
    firstLog.addQuery('message', 'like', 'Connection');
    firstLog.setLimit(1);
    firstLog.selectAttributes(['message', 'sys_created_at']);
    firstLog.query();
    firstLog.nexttimezone_id', current.getValue('timezone_id'));
    user.selectAttributes('sys_id');
    user.query();
    ss.info(firstLog.sys_created_atuser.getRowCount() + ' - ' + firstLog.messageusers have the same timezone as you');
    // Info: 2021-06-03 06:34:02 - IMAP IMAP (Default): Connection error: ...
    orderByDesc(column
    24 users have the same timezone as you

    hasAttachment()


    This method sorts the records in the descending order.

    Parameter(s):

    NameTypeMandatoryDefault ValuecolumnStringYN

    checks whether the record specified has an attachment or not.


    Return:

    TypeDescription
    VoidThis method does not return a value
    BooleanMethod returns 'true' if the record has an attachment; otherwise, it returns 'false'.


    Example:

    Code Block
    languagejs
    themeEclipse
    titleorderByDeschasAttachment
    linenumberstrue
    const lastCommentcurrent = new SimpleRecord('sys_activities_stream_fieldtask');
    lastCommentcurrent.orderByDescget('sys_created_at163663310116371174');
    const //hasAttach newest record first
    lastComment.setLimit(1);
    lastComment.selectAttributes(['value', 'sys_created_by']);
    lastComment.query();
    lastComment.next();
    ss.info(lastComment.sys_created_by.display_name + ': ' + lastComment.value);
    // Info: John Doe: test

    query()

    This method applies query to the database selection. After this, it fills in the record set.

    = current.hasAttachment();
    if (!hasAttach) {
      ss.addErrorMessage('File should be attached');
      return;
    }
    current.state = '2'; // Open
    current.update();


    initialize()


    This method populates all active empty fields with their predefined default values.

    It works only for new records that were never saved and cannot be called repeatedly.

    This method is called automatically and implicitly at the first set operation (also known as "the setter").


    Return:

    TypeDescription
    VoidThis method does not return a value.


    Example:

    Code Block
    languagejs
    themeEclipse
    titlequeryinitialize
    linenumberstrue
    const taskstaskRecord = new SimpleRecord('task');
    tasksss.addQuery('sys_created_at', '>', '2020-01-01');
    tasks.orderBy('sys_created_at');
    tasks.setLimit(5);
    tasks.queryinfo(taskRecord.getAttributes().caller);
    taskRecord.initialize();
    whiless.info(taskstaskRecord.nextgetAttributes().caller){
    ss.info('Tasks numbers: ' +  tasks.number);
    };
    // Info: 
    // RQTSK0000001, CHG0000004, CHG0000006, CHG0000007, CHG0000008
    selectAttributes(attributes
    Info: 155931135900000001

    insert()


    This method is intended to optimize database queries. Sometimes, it is necessary to obtain only several object fields, not the whole object. Therefore, this method was added.

    Warning

    uses the field values of the current record to insert a new one.


    If the record is not inserted then method returns '0' (zero) and adds an informative error message which can be obtained with getErrors() method.


    Return:

    TypeDescription
    String
    • If record was not inserted, then method returns '0' and you can get a message containing list of errors.
    • As a normal case, a unique ID of the inserted record returns.


    Example:

    Code Block
    languagejs
    themeEclipse
    titleinsert
    linenumberstrue
    const newTask

    Do not use this method to select records that could be updated or deleted after selecting. Otherwise, some of the record field values may be lost when these records are updated or deleted. Or the action performed may throw an exception looking like this (the example text is given below):

    Info

    You cannot save an incomplete record.

    NameTypeMandatoryDefault ValueattributesString or ArrayYN
    Info

    It makes sense to pass a single attribute name as a string. But if you need to pass more than one attribute names, please use Array type (as shown in code example below).

    Return:

    TypeDescriptionSimpleRecord object

    This method returns a SimpleRecord object containing attributes and values.

    Note

    Regardless of the initial attribute set content, the returned object always contains the sys_id attribute. See code examples below for more clarity.

    Example:

    Code Block
    languagejs
    themeEclipse
    titleselectAttributes (String)
    linenumberstrue
    const record = new SimpleRecord('usertask');
    record.selectAttributes('email');
    record.querynewTask.subject = 'Subtask';
    const inserterTaskID = newTask.insert();
    record.next();
    ss.info(record.getAttributes())`/record/task/${inserterTaskID}`);
    // Info: {"email":"john.doe@email.com","sys_id":"162423321917274937"}/record/task/163675231910113745

    isTableVcsEnabled()


    This method checks whether the VCS enabled attribute is enabled against the specified table or not. 


    Return:

    TypeDescription
    BooleanThis method returns the value of the is_vcs_enabled attribute of record table.

    Example:

    Code Block
    languagejs
    themeEclipse
    titleselectAttributes (Array)isTableVcsEnabled
    linenumberstrue
    const recordcurrent = new SimpleRecord('user');
    record.selectAttributes(['email', 'username']);
    record.query();
    record.next();
    ss.info(record.getAttributes());
    ss.info(current.isTableVcsEnabled());
    // Info: {"email":"john.doe@email.com","username":"john.doe","sys_id":"162423321917274937"}
    setAbortAction(flag
    false


    matchesCondition(condition)


    This method is used in business rules and sets a flag, indicating that the current operation (insert/update/delete) will be interrupted.

    Note

    Please note that the code will not be executed if it is typed after calling this method in the script body.

    Note

    checks whether the current record meets the condition in the current state.


    It is not recommended to use thismethod with async business rules. It may cause unpredictable system behavior.

    Parameter(s):

    NameTypeMandatoryDefault Value
    flag
    condition
    Boolean
    String
    Y
    N
    N
    ''


    Return:

    TypeDescription
    Void
    BooleanThis method
    does not return a value.
    Example:
    returns 'true' if the record meets the condition specified; otherwise; it returns 'false'.


    Code Block
    languagejs
    themeEclipse
    titlesetAbortActionmatchesCondition
    linenumberstrue
    const currenttask = new SimpleRecord('task');
    current.get('163663310116371174');
    const hasAttach = current.hasAttachment();
    current.setAbortAction(!hasAttachtask.description = 'emaio';
    ss.info(task.matchesCondition('descriptionLIKEemail')); // same as return;
    current.statefalse
    task.description = '2email'; // Open
    current.update();
    setLimit(maxNumRecords
    
    ss.info(task.matchesCondition('descriptionLIKEemail')); // true

    next()


    N

    This method limits the number of records selected by SimpleRecord query methods.

    Parameter(s):

    NameTypeMandatoryDefault ValuemaxNumRecordsIntegerY

    returns the next record in the query. If this is the first call, this method returns the first record in query. If the query is empty, this method returns 'false'.


    Return:

    Type
    DescriptionVoidThis method does not return a value.
    Record or Boolean


    Example:

    Code Block
    languagejs
    themeEclipse
    titlesetLimitnext
    linenumberstrue
    const recorduser = new SimpleRecord('user');
    recorduser.setLimit(31);
    recorduser.query();
    user.next();
    ss.info(record.getRowCount()user.sys_id);
    // Info: 3

    setMultipleValue(property,value)

    This method sets the properties values for every entry in the current selection.

    Parameter(s):

    NameTypeMandatoryDefault ValuepropertyStringYNvalueStringYN

    Return:

    TypeDescriptionVoid

    This method does not return a value.

    100000000000000000


    Note

    Until the method is called, the values of a SimpleRecord object are not available, and the 'Current record is not set' message will occur. Consider the example:

    Code Block
    languagejs
    themeEclipse
    const task = new SimpleRecord('task');
    task.setLimit(1);
    task.query();
    // task.next
    Code Block
    languagejs
    themeEclipse
    titlesetMultipleValue
    linenumberstrue
    const task = new SimpleRecord('task'); task.addQuery('state', '7'); // Draft task.query
    ();
    ss.info(task.
    getRowCount(
    number)
    )
    ;
    
    task.setMultipleValue('state', '2');
    //
    Open // task.updateMultiple();
    setReModelId(reModelId)  AnchorsetremodelidsetremodelidThis method sets the ID of the defined RE model. To get the model ID, use the getReModelId method
     Error: Current record is not set.



    orderBy(column)


    This method sorts records in the ascending order.


    Tip

    Call this method several times to order by multiple columns.


    Parameter(s):

    NameTypeMandatoryDefault Value
    reModelId
    columnStringYN

    If the reModelId parameter is equal to 'null', the REM, related to the record, will be detached. 


    Return:

    TypeDescription
    VoidThis method does not
    return a
    return a value.


    Example:

    Code Block
    languagejs
    themeEclipse
    titlegetReModelIdorderBy
    linenumberstrue
    const task = new SimpleRecord('task');
    task.get('163352033916904699');
    if (task.getValue('service') === '164069027812962298') { // Email Server Service
        task.setReModelId('158569205818704980'); // Email Server Access Request
    } else {
        task.setReModelId(null);
    }
    task.update();firstLog = new SimpleRecord('sys_log');
    firstLog.orderBy('sys_created_at'); // oldest record first
    firstLog.addQuery('message', 'like', 'Connection');
    firstLog.setLimit(1);
    firstLog.selectAttributes(['message', 'sys_created_at']);
    firstLog.query();
    firstLog.next();
    ss.info(firstLog.sys_created_at + ' - ' + firstLog.message);
    // Info: 2021-06-03 06:34:02 - IMAP IMAP (Default): Connection error: ...


    orderByDesc(column)


    This method sorts the records in the descending order.


    Parameter(s):

    NameTypeMandatoryDefault Value
    columnStringYN


    Return:

    TypeDescription
    VoidThis method does not return a value.


    Example:

    Code Block
    languagejs
    themeEclipse
    titleorderByDesc
    linenumberstrue
    const lastComment = new SimpleRecord('sys_activities_stream_field');
    lastComment.orderByDesc('sys_created_at'); // newest record first
    lastComment.setLimit(1);
    lastComment.selectAttributes(['value', 'sys_created_by']);
    lastComment.query();
    lastComment.next();
    ss.info(lastComment.sys_created_by.display_name + ': ' + lastComment.value);
    // Info: John Doe: test

    query()


    This method applies query to the database selection. After this, it fills in the record set.

    Return:

    TypeDescription
    VoidThis method does not return a value.


    Example:

    Code Block
    languagejs
    themeEclipse
    titlequery
    linenumberstrue
    const tasks = new SimpleRecord('task');
    tasks.addQuery('sys_created_at', '>', '2020-01-01');
    tasks.orderBy('sys_created_at');
    tasks.setLimit(2);
    tasks.query();
    while (tasks.next()) {
      ss.info('Task number: ' +  tasks.number);
    }
    // Info: Task number: TSK0000001
    // Info: Task number: TSK0000003


    selectAttributes(attributes)


    This method is intended to optimize database queries. Sometimes, it is necessary to obtain only several object fields, not the whole object. Therefore, this method was added.


    Warning

    Do not use this method to select records that could be updated or deleted after selecting. Otherwise, some of the record field values may be lost when these records are updated or deleted. Or the action performed may throw an exception looking like this (the example text is given below):

    Info

    You cannot update the record with the set of shortened attributes. Remove the selectAttributes method call and update again.



    NameTypeMandatoryDefault Value
    attributesString or ArrayYN


    Info

    It makes sense to pass a single attribute name as a string. But if you need to pass more than one attribute names, please use Array type (as shown in code example below).


    Return:

    TypeDescription
    SimpleRecord object

    This method returns a SimpleRecord object containing attributes and values.

    Note

    Regardless of the initial attribute set content, the returned object always contains the sys_id attribute. See code examples below for more clarity.


    Example:

    Code Block
    languagejs
    themeEclipse
    titleselectAttributes (String)
    linenumberstrue
    const record = new SimpleRecord('user');
    record.selectAttributes('email');
    record.query();
    record.next();
    ss.info(record.getAttributes());
    // Info: {"email":"john.doe@email.com","sys_id":"162423321917274937"}


    Example:

    Code Block
    languagejs
    themeEclipse
    titleselectAttributes (Array)
    linenumberstrue
    const record = new SimpleRecord('user');
    record.selectAttributes(['email', 'username']);
    record.query();
    record.next();
    ss.info(record.getAttributes());
    // Info: {"email":"john.doe@email.com","username":"john.doe","sys_id":"162423321917274937"}

    setAbortAction(flag)


    This method is used in business rules and sets a flag, indicating that the current operation (insert/update/delete) will be interrupted.


    Note

    Please note that the code will not be executed if it is typed after calling this method in the script body.


    Note

    It is not recommended to use thismethod with async business rules. It may cause unpredictable system behavior.


    Parameter(s):

    NameTypeMandatoryDefault Value
    flagBooleanYN


    Return:

    TypeDescription
    VoidThis method does not return a value.


    Example:

    Code Block
    languagejs
    themeEclipse
    titlesetAbortAction
    linenumberstrue
    const current = new SimpleRecord('task');
    current.get('163663310116371174');
    const hasAttach = current.hasAttachment();
    if (!hasAttach) {
        ss.addErrorMessage('File should be attached!');
        current.setAbortAction(true);
    }
    current.state = '2'; // Open
    current.update();

    setLimit(maxNumRecords)


    This method limits the number of records selected by SimpleRecord query methods.


    Parameter(s):

    NameTypeMandatoryDefault Value
    maxNumRecordsIntegerYN


    Return:

    TypeDescription
    VoidThis method does not return a value.


    Example:

    Code Block
    languagejs
    themeEclipse
    titlesetLimit
    linenumberstrue
    const record = new SimpleRecord('user');
    record.setLimit(3);
    record.query();
    ss.info(record.getRowCount());
    // Info: 3


    setMultipleValue(property,value)


    This method sets the properties values for every entry in the current selection.


    Parameter(s):

    NameTypeMandatoryDefault Value
    propertyStringYN
    valueStringYN

    Return:

    TypeDescription
    Void

    This method does not return a value.


    Code Block
    languagejs
    themeEclipse
    titlesetMultipleValue
    linenumberstrue
    const task = new SimpleRecord('task');
    task.addQuery('state', '7'); // Draft
    task.query();
    ss.info(task.getRowCount());
    task.setMultipleValue('state', '2'); // Open
    // task.updateMultiple();

    setReModelId(reModelId) 
    Anchor
    setremodelid
    setremodelid


    This method sets the ID of the defined RE model. To get the model ID, use the getReModelId method.

    Parameter(s):

    NameTypeMandatoryDefault Value
    reModelIdStringYN

    If the reModelId parameter is equal to 'null', the REM, related to the record, will be detached. 

    Return:

    TypeDescription
    Void

    This method does not return a value.

    Example:

    Code Block
    languagejs
    themeEclipse
    titlegetReModelId
    linenumberstrue
    const task = new SimpleRecord('task');
    task.get('163352033916904699');
    if (task.getValue('service') === '164069027812962298') { // Email Server Service
        task.setReModelId('158569205818704980'); // Email Server Access Request
    } else {
        task.setReModelId(null);
    }
    task.update();


    Note

    When calling the method on a SimpleRecord() instance, the values of its attributes bound to the previous model will be reset.

    After calling the method and updating the сurrent record, the attribute values bound to the previous model will be lost.

    Example:

    Code Block
    languagejs
    themeEclipse
    titlesetReModelId
    linenumberstrue
    (function executeRule(current, previous = null /*not null only when action is update*/ ) {
        // before rule triggered by service change
    
        ss.importIncludeScript('getRemAttributes');
        const rmc = new SimpleRecord('sys_rmc_model');
        rmc.addQuery('cmdb_service_id', current.getValue('service'));
        rmc.addQuery('active', true);
        rmc.selectAttributes('sys_id');
        rmc.setLimit(1);
        rmc.query();
        if (rmc.next()) {
            const previousModelAttributes = getRemAttributes(current);
            current.setReModelId(rmc.sys_id);
            const currentModelAttributes = getRemAttributes(current);
    
            Object.keys(previousModelAttributes).forEach(attributeName => {
                if (currentModelAttributes.hasOwnProperty(attributeName)) {
                    current.rem_attr[attributeName] = previousModelAttributes[attributeName];
                }
            })
        } else {
            current.setReModelId(null);
        }
    
    })(current, previous);
    Note

    When calling the method on a SimpleRecord() instance, the values of its attributes bound to the previous model will be reset.

    After calling the method and updating the сurrent record, the attribute values bound to the previous model will be lost.

    setValue(property, value) 
    Anchor
    setValue()
    setValue()


    This method sets the value of the field in the current record.

    Parameter(s):

    NameTypeMandatoryDefault Value
    propertyStringYN
    valueStringYN


    Return:

    TypeDescription
    VoidThis property does not return a value.


    Example:

    Code Block
    languagejs
    themeEclipse
    titlesetValue
    linenumberstrue
    const task = new SimpleRecord('task');
    task.setValue('subject', 'mail');
    task.insert();


    silentMode(enable)


    This method is intended to update the record without executing any entities related to this record implementing the business logic, such as business rules, notifications, workflows, etc.


    NameTypeMandatoryDefault Value
    enableBooleanNtrue


    TypeDescription
    VoidThis property does not return a value.


    Code Block
    languagejs
    themeEclipse
    titlesilentMode
    linenumberstrue
    const task = new SimpleRecord('task');
    task.addQuery('active', false);
    task.addQuery('approval_state', 'isempty');
    task.query();
    ss.info(task.getRowCount());
    task.silentMode();
    task.setMultipleValue('approval_state', 'not_requested'); // set Default Value
    //task.updateMultiple();

    update()


    This method updates a database record.

    Info

    This method is used for existing records.

    • If the record existed before, the changes are applied.
    • If the record did not exist before, the getErrors() method will return this error: "Unable to update new record. Use `insert()` instead. (record id: )"


    Return:

    TypeDescription
    IntegerString
    • If record was not updated, then method returns '0' and you can get a message containing list of errors;
    • As a normal case, an ID of the updated record returns.


    Example:

    Code Block
    languagejs
    themeEclipse
    titleupdate
    linenumberstrue
    const current = new SimpleRecord('taskuser');
    current.get('undefined'(ss.getUserId());
    current.subjecttimezone_id = 'Test156076775207670452'; // UTC
    ss.info(current.update());
    ss.info(current.getErrors());
    // Info: 0155931135900000001
    // Info: ["Invalid condition query: Use only digits","Unable to update new record. Use `insert()` instead. (record id: )"]


    updateMultiple()


    This method updates all the selection entries.

    Return:

    TypeDescription
    Void or Integer
    • If validation errors occurred and record was not updated, then method returns '0' and you can get a message containing list of errors;
    • Normally, this method does not return a value.


    Code Block
    languagejs
    themeEclipse
    titleupdateMultiple
    linenumberstrue
    const task = new SimpleRecord('task');
    task.addQuery('state', '0'); // Open
    task.query();
    ss.info(task.getRowCount());
    task.setMultipleValue('state', '10'); // Canceled
    // task.updateMultiple();


    Table of Contents
    absoluteUrltrue
    printablefalse