This server class provides methods to operate database records.
SimpleRecord(tableName)
This method instantiates a SimpleRecord class object for a particular table.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
tableName | String | Y | N |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | SimpleRecord |
---|
linenumbers | true |
---|
|
const tasktaskRecord = new SimpleRecord('task');
task.get('162494866118348768'); |
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 that you need to use system name of the operator in your scripts.
REM attribute object
The SimpleRecord class has a special object for Record Extended Models – rem_attr – containing information about the REM attributes. It is used to read and 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');
|
ParameterParameter(s):
Name | Type | Mandatory | Default Value |
---|
property | String | Y | N |
operator | String (refer to the Condition Operators article for more information) | N | N |
value | Integer or String or Boolean or Array | Y | N |
ReturnReturn:
Type | Description |
---|
SimpleRecord |
The query containing OR condition added to object | This 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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | addOrConditionget using REM |
---|
linenumbers | true |
---|
|
const taskrecord = new SimpleRecord('task');
taskrecord.addQueryget('subject', 'like', 'not work')
.addOrCondition('description', 'like', 'not work');
task.query();
160638931615274614');
if (record.getReModelId()) {
ss.info(task.getRowCount());
task.setMultipleValue('attention_required', true);
// task.updateMultiple(); |
addQueryrecord.rem_attr.description);
} |
addOrCondition(property, operator, value)
This method adds a condition to make a selection of records from the database. 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 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.
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):
Name | Type | Mandatory | Default Value |
---|
property | String | Y | 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. |
|
operator | String ( |
refer or or Array
Return:
Type | Description |
---|
SimpleRecord | The query containing OR condition added to the SimpleRecord object. |
ExampleExamples:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addQueryaddOrCondition |
---|
linenumbers | true |
---|
|
const taskrecord = new SimpleRecord('task');
task.addQuery('active', true);
taskrecord.addQuery('subject', 'like', 'emailnot work');
taskrecord.addQueryaddOrCondition('sys_created_atdescription', '<like', '2019-04-01 00:00:00');
task.query(not work');
ss.info('CountCondition query: ' + taskrecord.getRowCountgetConditionQuery()); |
addEncodedQuery(condition)
This method adds encoded query and applies it to the current query method.
Parameter(s)
Name | Type | Mandatory | Default Value |
---|
condition | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
record.query();
// Info: Condition query: (subjectLIKEnot work)^OR(descriptionLIKEnot work) |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addEncodedQueryaddOrCondition with REM attribute |
---|
linenumbers | true |
---|
|
constlet employeerecord = new SimpleRecord('employeetask');
employeerecord.addEncodedQueryaddQuery('%28locked_out%3D0%29%5EmanagerISEMPTY'subject', 'like', 'not work');
ssrecord.infoaddOrCondition('Decoded condition: ' + employee.166972638116358001:description', 'contains', 'not work');
ss.info('Condition query: ' + record.getConditionQuery());
employeerecord.query();
// Info: DecodedCondition conditionquery: ((locked_out=0)^managerISEMPTY) |
canCreate()
This method checks whether inserting new records in this table satisfies the Access Control Rule.
Also, you can use this method in your UI Actions to adjust its visibility more precisely.
Return:
Type | Description |
---|
Boolean | The method returns 'true' if this operation is permitted; otherwise it returns 'false'. |
subjectLIKEnot work)^OR(166972638116358001:descriptionLIKEnot work) |
Example:
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: |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title |
---|
|
| canCreatePassing SimpleRecord as an argument | linenumbers | true |
---|
|
|
current.canCreate(); |
canDelete()
This method checks whether deleting records in this table satisfies the Access Control Rule.
Also, you can use this method in your UI Actions to adjust its visibility more precisely.
Return:
Type | Description |
---|
Boolean | The method returns 'true' if this operation is permitted; otherwise it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | canDelete |
---|
linenumbers | true |
---|
|
current.canDelete(); |
canRead()
This method checks whether reading records in this table satisfies the Access Control Rule.
Also, you can use this method in your UI Actions to adjust its visibility more precisely.
Return:
Type | Description |
---|
Boolean | The method returns 'true' if this operation is permitted; otherwise it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | canRead |
---|
linenumbers | true |
---|
|
current.canRead(); |
canUpdate()
This method checks whether updating records in this table satisfies the Access Control Rule.
Also, you can use this method in your UI Actions to adjust its visibility more precisely.
Return:
Type | Description |
---|
Boolean | The method returns 'true' if this operation is permitted; otherwise it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | canUpdate |
---|
linenumbers | true |
---|
|
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. | const task = new SimpleRecord('task');
task.setLimit(1);
task.query();
if (!task.next()) {
ss.info('No tasks found!');
return;
}
const relatedTask = new SimpleRecord('task');
relatedTask.addQuery('caller', task.caller);
relatedTask.addOrCondition('assigned_user', task.caller);
relatedTask.query();
ss.info('Tasks count: ' + relatedTask.getRowCount());
// Info: Tasks 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):
Name | Type | Mandatory | Default Value |
---|
property | String | Y | 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. |
|
operator | String (refer to the Condition Operators article for more information) | N | N |
value | Integer or String or Boolean or Array or SimpleRecord object | Y | N |
Return:
Boolean | This method returns 'true' if records are deleted successfully; otherwise, it returns 'false'. |
SimpleRecord | The query condition added to the SimpleRecord object. |
ExamplesExample:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | deleteMultipleaddQuery |
---|
linenumbers | true |
---|
|
const recordtask = new SimpleRecord('sys_translationtask');
recordtask.addQuery('valueactive', 'liketrue);
task.addQuery('subject', 'like', 'email');
task.addQuery('sys_created_at', 'network'<', '2019-04-01 00:00:00');
recordtask.query();
ss.info(record'Count: ' + task.getRowCount());
// record.deleteMultiple(); |
deleteRecord()
This method deletes the current record.
Return:
Type | Description |
---|
Boolean | This method returns 'true' if the record is deleted successfully; otherwise it returns 'false'. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addQuery with REM attribute |
---|
|
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | deleteRecord |
---|
linenumbers | true |
---|
|
constlet incidentrecord = new SimpleRecord('itsm_incidenttask');
incidentrecord.getaddQuery('155931135900000000'166972638116358001:description', 'not work');
if (incident.sys_id) {
const wasDeleted = incident.deleteRecord();
if (wasDeleted) {
ss.info('Incident ' + incident.sys_id + ' was deletedrecord.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: Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Passing SimpleRecord as an argument |
---|
linenumbers | true |
---|
collapse | true |
---|
| const task = new SimpleRecord('task');
task.setLimit(1);
task.query();
if (!task.next()) {
ss.info('No tasks found!');
return;
}
const | else{
ss.error('Errors: ' + incident.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):
Name | Type | Mandatory | Default 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". |
new SimpleRecord('task');
otherTask.addQuery('caller', task.caller);
otherTask.addQuery('sys_id', '!=', task.sys_id);
otherTask.query();
ss.info('Tasks count: ' + otherTask.getRowCount());
// Info: Tasks count: 720 |
|
addEncodedQuery(condition)
This method 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.
Y | N | value | String | N | NULL |
Return:
Type | Description |
---|
SimpleRecord object | This method returns the SimpleRecord object from the table specified in the query. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getFilter with text fields |
---|
linenumbers | true |
---|
collapse | true |
---|
|
const service subject = 'Hello, SimpleOne)';
const task = new SimpleRecord('c_servicetask');
servicetask.get(current.getValue('service'));
if (!!service.sys_id)addEncodedQuery(`subjectLIKE${subject}`);
ss.info(task.getConditionQuery());
try {
const company = new SimpleRecord('org_company');
company.get('link', service.customer_url);
ss.eventQueue('notify.responsible', current, company.responsible.email);
} |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | get using REM |
---|
linenumbers | true |
---|
|
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
ss.info(record.rem_attr.description); // In there, we have called the RE attribute as a property |
getAttributes()
This method returns an object with current record properties as keys and properties values as key values.
Return:
Type | Description |
---|
Object | The array containing attributes. |
task.query();
} catch (e) {
ss.error(e.message);
}
// Info: (subjectLIKEHello, SimpleOne))
// Error: Condition query is invalid |
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
condition | String | 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:
Type | Description |
---|
Void | This method does not return a value. |
Examples:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addEncodedQuery |
---|
linenumbers | true |
---|
|
const currentUser = ss.getUser();
const receiver = new SimpleRecord('employee');
receiver.addQuery('active', true);
if (currentUser.company.class === 'internal') {
receiver.addEncodedQuery(`(company=${currentUser.getValue('company')})`);
} else {
receiver.addEncodedQuery(`%28sys_db_table_id%3D158645243815904649%5Esys_created_byDYNAMIC156957117519820256%29`);
}
ss.info('Decoded condition: ' + receiver.getConditionQuery());
receiver.query( |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getAttributes |
---|
linenumbers | true |
---|
|
const userRecord = ss.getUser();
ss.info(userRecord.getAttributes());
// 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:
Type | Description |
---|
String | Title or name. |
Decoded condition: (active=1)^((sys_db_table_id=158645243815904649^sys_created_byDYNAMIC156957117519820256)) |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addEncodedQuery with REM attributes |
---|
|
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getClassDisplayValue |
---|
linenumbers | true |
---|
|
const taskTitlereceier = current.getClassDisplayValue(new SimpleRecord('task');
receiver.addQuery('active', true);
emailreceiver.setSubjectaddEncodedQuery('New ' + taskTitle + ' has been created'); |
getConditionQuery()
This method returns current query condition%28sys_db_table_id%3D158645243815904649%5E166972638116358001%3AdescriptionLIKEwork`);
ss.info('Decoded condition: ' + receiver.getConditionQuery());
receiver.query();
// Info: Decoded condition: (active=1)^((sys_db_table_id=158645243815904649^166972638116358001:descriptionLIKEwork)) |
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:
String | The query conditionBoolean | The method returns 'true' if this operation is permitted; otherwise, it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getConditionQuerycanCreate |
---|
linenumbers | true |
---|
|
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)
This method returns the displayed field value (the 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):
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:
Type | Description |
---|
Boolean | The method returns 'true' if this operation is permitted; otherwise, it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | canDelete |
---|
linenumbers | true |
---|
|
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:
Type | Description |
---|
Boolean | The method returns 'true' if this operation is permitted; otherwise, it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | canRead |
---|
linenumbers | true |
---|
|
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.
Name | Type | Mandatory | Default Value |
---|
Property | String | N | NULL |
Return:
String | A field or record valueBoolean | The method returns 'true' if this operation is permitted; otherwise, it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDisplayValuecanUpdate |
---|
linenumbers | true |
---|
|
const companyName = current.getDisplayValuecanUpdate('company');
email.setSubject('New employee at "' + companyName + '" company'); |
getErrors()
If the record creating, updating or deleting fails, then this method will display 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:
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:
Type | Description |
---|
Boolean | This method returns 'true' if records are deleted successfully; otherwise, it returns 'false' |
Type | Description |
---|
Array | The error value
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getErrorsdeleteMultiple |
---|
linenumbers | true |
---|
|
const record = new SimpleRecord('usersys_activity_feed_item');
const newUserID = record.insertrecord.addQuery('content', 'isempty');
record.query();
if (newUserID == 0) {
ss.info(record.getRowCount());
ss.info(record.getErrorsdeleteMultiple());
}
// Info: ["The \"\"First Name\" [first_name]\" field is mandatory. (record id: )",... |
getLabel(property
deleteRecord()
Name | Type | Mandatory | Default Value |
---|
property | String | Y | NThis method gets deletes the field title.
Parameter(s):
current record.
Return:
String | The field nameBoolean | This method returns 'true' if the record is deleted successfully; otherwise it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLabeldeleteRecord |
---|
linenumbers | true |
---|
|
const currenttask = new ss.getUser(SimpleRecord('task');
const fieldLabel = current.getLabeltask.get('username155931135900000000');
ss.addErrorMessage('Field "' + fieldLabelif (!task.sys_id) {
return;
}
const isDeleted = task.deleteRecord();
if (isDeleted) {
ss.info('Task with ID ' + task.sys_id + '" cannot be blankwas deleted!');
// Field "Login" cannot be blank |
getRowCount( return;
}
ss.error(task.getErrors()); |
get(propertyOrValue, value)
This method gets the amount of items in a row.
Returns:
Type | Description |
---|
Integer | Items amount in a row specified. |
loads an object from a database by the field value, or, in a specific case, by the sys_id.
Parameter(s):
Name | Type | Mandatory | Default 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 causes an exception: "Argument 1 passed to "get()" must not be empty". |
| Y | N |
value | String or SimpleRecord object | N | NULL |
Return:
Type | Description |
---|
SimpleRecord object | This method returns a SimpleRecord object from the table specified in the query. |
Example:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getRowCountget |
---|
linenumbers | true |
---|
|
const incidenttask = new SimpleRecord('itsm_incidenttask');
incidenttask.queryget('163663310116371174');
ss.addInfoMessage('Total incident count: ' + incident.getRowCount()); |
getTableName()
This method gets the current table name.
Return:
Type | Description |
---|
String | The current table name. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getTableName |
---|
linenumbers | true |
---|
|
const current = ss.getUser();
ss.info('/list/' + current.getTableName());
// Info: /list/user |
getValue(property)
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(s):
Name | Type | Mandatory | Default Value |
---|
property | String | Y | N |
Return:
Type | Description |
---|
Mixed | The string value of the object property. |
// 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: Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title |
---|
|
| getValuePassing SimpleRecord as an argument | linenumbers | true |
---|
collapse | true |
---|
| const | currentss.getUser();
const user = useruseraddQuery('timezone_id', current.getValue('timezone_id'));
user.query();
ss.info('Same timezone for: ' + user.getRowCount() + ' users');
// Info: Same timezone for: 36 users |
hasAttachment()
This method checks whether the record specified has an attachment or notsetLimit(1);
task.query();
if (!task.next()) {
ss.info('No tasks found!');
return;
}
const user = new SimpleRecord('user');
user.get(task.caller);
user.language_id = '156628684306541141'; // 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.
Return:
Boolean | Method returns 'true' if the record has an attachment; otherwise, it returns 'false'. |
Example:
Object | The array containing attributes. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | hasAttachmentgetAttributes |
---|
linenumbers | true |
---|
|
const hasAttachuserRecord = currentss.hasAttachmentgetUser();
if (!hasAttach) {
ss.addErrorMessage('File should be attached'ss.info(userRecord.getAttributes());
// current.setAbortAction(true);
} |
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.
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 nameThis method is called automatically and implicitly at the first set operation (also known as "the setter").
Return:
Void | This method does not return a value
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | initializegetClassDisplayValue |
---|
linenumbers | true |
---|
|
const taskRecordcurrent = new SimpleRecord('task');
current.get('163663310116371174');
ss.info(Object.entries(taskRecord.getAttributes()).filter(item => !item.includes('')));
taskRecord.initialize();
ss.info(Object.entries(taskRecord.getAttributes()).filter(item => !item.includes('')))current.getClassDisplayValue());
// Info: Task |
getConditionQuery()
This method returns current query condition.
Return:
Type | Description |
---|
String | The query condition. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getConditionQuery |
---|
linenumbers | true |
---|
|
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: [["active",1],["state",7],["opened_at","2021-06-29 10:06:38"],... |
insertgetDisplayValue(property)
Anchor |
---|
| getDisplayValue() |
---|
| getDisplayValue() |
---|
|
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.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):
Name | Type | Mandatory | Default Value |
---|
Property | String | N | NULL |
Return:
Integer | - If validation errors occurred and record was not updated, 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:
String | A field or record value. |
Example:
Code Block |
---|
|
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | insertgetDisplayValue |
---|
linenumbers | true |
---|
|
const newTaskcurrent = new SimpleRecord('task');
newTask.subject = `New task`;
const inserterTaskID = newTask.insert();
if (inserterTaskID != 0) {
current.parent_id = inserterTaskID;
} else {
ss.addErrorMessage('Errors: ' + JSON.stringify(newTask.getErrors()));
} |
isTableVcsEnabled()
This method checks whether the VCS enabled attribute is enabled against the specified table or not.
Return:
Type | Description |
---|
Boolean | This method returns the value of the is_vcs_enabled attribute of record table. |
current.get('163663310116371174');
ss.info(current.getDisplayValue('caller'));
ss.info(current.getValue('caller'));
// Info: John Doe
// Info: 155931135900000001 |
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:
Type | Description |
---|
Array | The error value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | isTableVcsEnabledgetErrors |
---|
linenumbers | true |
---|
|
const tablerecord = new SimpleRecord('sys_db_table');
user');
const insertedRecordId = record.insert();
if (insertedRecordId == 0) {
ss.info(tablerecord.isTableVcsEnabledgetErrors());
}
// true |
matchesCondition(condition)
This method checks whether the current record meets the condition in the current state.
Info: ["The \"\"First Name\" [first_name]\" field is mandatory. (record id: )",... |
getLabel(property)
This method gets the field title.
Info |
---|
The getLabel() method cannot be used with REM attributes. Instead, use the getTitle() method. |
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
condition'' |
Return:
Boolean | This method returns 'true' if the record meets the condition specified; otherwise; it returns 'false'. |
Example:
Code Blockcode |
---|
language | js |
---|
theme | Eclipse |
---|
title | matchesConditiongetLabel |
---|
linenumbers | true |
---|
|
const taskcurrent = new SimpleRecord('task'ss.getUser();
task.descriptionconst fieldLabel = current.getLabel('emaikusername');
ss.infoaddErrorMessage(task.matchesCondition('descriptionLIKEemail')); // false
task.description = 'email';
ss.info(task.matchesCondition('descriptionLIKEemail')); // true |
next()
'Field "' + 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 methodIf this is a new request, then this method returns the first record from the list; otherwise it returns FALSE, in the case if the record is unavailable.
Return:
Example:
Description |
---|
String | The method returns the ID of the model. If model is not found, the method returns null. |
Example:
Code Block |
---|
|
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | nextgetReModelId |
---|
linenumbers | true |
---|
|
const user(function executeRule(current, previous = new SimpleRecord('user');
user.setLimit(1);
user.query();
user.next();
ss.info(user.sys_id);
// Info: 100000000000000000 |
orderBy(column)
This method sorts records in the ascending order.
Tip |
---|
Call this method several times to order by multiple columns. |
Parameter(s):Name | Type | Mandatory | Default Value |
---|
column | String | Y | N |
Returnnull /*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:
Void | This method does not return a valueInteger | Items amount in a row specified. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | orderBygetRowCount |
---|
linenumbers | true |
---|
|
const firstLogtask = new SimpleRecord('sys_logtask');
firstLogtask.orderBy('sys_created_at'); // oldest record first
firstLog.addQuery('message', 'like', 'Connection');
firstLog.setLimit(1);
firstLog.selectAttributes(['message', 'sys_created_at']);
firstLog.query();
firstLog.nextquery();
ss.addInfoMessage('All Tasks Count: ' + task.getRowCount());
// All Tasks Count: 2 |
getTableName()
This method gets the current table name.
Return:
Type | Description |
---|
String | The current table name. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getTableName |
---|
linenumbers | true |
---|
|
const current = ss.getUser();
ss.info('[/list/' + firstLog.sys_created_atcurrent.getTableName() + ']: /' + firstLogcurrent.messagesys_id);
// Info: [2021-06-03 06:34:02]: IMAP IMAP (Default): Connection error: ... |
orderByDesc(column/list/user/155931135900000001 |
getTitle(attribute)
This method sorts returns the records in the descending ordertitle of the defined RE attribute.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
column | String | Y | N |
Return:
Void does not return a valuereturns the title of the attribute. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | orderByDescgetTitle |
---|
linenumbers | true |
---|
|
const lastCommentcurrent = new SimpleRecord('sys_activities_stream_fieldtask');
lastCommentcurrent.orderByDescget('sys_created_at163638951512716126'); // newest record first
lastComment.setLimit(1);
lastComment.selectAttributes(['value', 'sys_created_by']);
lastComment.query();
lastComment.next();
if (current.sys_id) {
ss.info(lastCommentcurrent.sysrem_created_by.display_name + ': ' + lastComment.value);attr.getTitle('reviewed'));
}
// Info: Admin null: test |
query()
This method applies query to the selection from a database, based on the $this→query. After this, it fills in the record set.
Return:
Type | Description |
---|
Void | This method does not return a value. |
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 |
---|
Info |
---|
To return column titles which are not part of REM, use the getLabel() method. |
getValue(property)
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(s):
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 can't save incomplete record. |
Name | Type | Mandatory | Default Value |
---|
attributes or Array 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:
Type | Description |
---|
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. |
Return:
Type | Description |
---|
Mixed | The string value of the object property. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | selectAttributes (String)getValue |
---|
linenumbers | true |
---|
|
const recordcurrent = new ss.getUser();
const user = new SimpleRecord('user');
record.selectAttributes('email'user.addQuery('timezone_id', current.getValue('timezone_id'));
recorduser.queryselectAttributes('sys_id');
recorduser.nextquery();
ss.info(recorduser.getAttributesgetRowCount() + ' users have the same timezone as you');
// Info: {"email":"john.doe@email.com","sys_id":"162423321917274937"}24 users have the same timezone as you |
hasAttachment()
This method checks whether the record specified has an attachment or not.
Return:
Type | Description |
---|
Boolean | Method returns 'true' if the record has an attachment; otherwise, it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | selectAttributes (Array)hasAttachment |
---|
linenumbers | true |
---|
|
const recordcurrent = new SimpleRecord('usertask');
recordcurrent.selectAttributesget(['email', 'username']);
record.query'163663310116371174');
const hasAttach = current.hasAttachment();
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. |
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
flag | Boolean | Y | N |
Return:
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:
Type | Description |
---|
Void | This method does not return a |
Type | Description |
---|
Void | This method does not return a
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setAbortActioninitialize |
---|
linenumbers | true |
---|
|
const NOWtaskRecord = new SimpleDateTimeSimpleRecord('task');
const appropriateDatetime = new SimpleDateTime(current.appropriate_date);
if (NOW.before(appropriateDatetime)) {
ss.addErrorMessage("Can't be updated before " + appropriateDatetime.getDisplayValue());
current.setAbortAction(true);
} |
setLimit(maxNumRecords)
This method limits the number of records selected by SimpleRecord query methods.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
maxNumRecords | Integer | Y | ss.info(taskRecord.getAttributes().caller);
taskRecord.initialize();
ss.info(taskRecord.getAttributes().caller);
// 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.
N
Return:
Void | This method does not return a valueString | - 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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | setLimitinsert |
---|
linenumbers | true |
---|
|
const recordnewTask = new SimpleRecord('usertask');
record.setLimit(1);
record.querynewTask.subject = 'Subtask';
const inserterTaskID = newTask.insert();
ss.info(record.getRowCount()`/record/task/${inserterTaskID}`);
// Info: 1 |
setMultipleValue(property,value/record/task/163675231910113745 |
isTableVcsEnabled()
This method sets the properties values for every entry in the current selection.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
property | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
checks whether the VCS enabled attribute is enabled against the specified table or not.
Return:
Type | Description |
---|
Boolean | This method returns the value of the is_vcs_enabled attribute of record table. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | isTableVcsEnabled |
---|
linenumbers | true |
---|
|
const current = new SimpleRecord('user');
ss.info(current.isTableVcsEnabled());
// Info: false |
matchesCondition(condition)
This method checks whether the current record meets the condition in the current state.
Name | Type | Mandatory | Default Value |
---|
condition | String | N | '' |
Return:
Type | Description |
---|
Boolean | This method returns 'true' if the record meets the condition specified; otherwise; it returns 'false'. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | matchesCondition |
---|
linenumbers | true |
---|
|
const task = new SimpleRecord('task');
task.description = 'emaio';
ss.info(task.matchesCondition('descriptionLIKEemail')); // false
task.description = 'email';
ss.info(task.matchesCondition('descriptionLIKEemail')); // true |
next()
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:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | next |
---|
linenumbers | true |
---|
|
const user = new SimpleRecord('user');
user.setLimit(1);
user.query();
user.next();
ss.info(user.sys_id);
// Info: 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 |
---|
| 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. |
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
column | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | orderBy |
---|
linenumbers | true |
---|
|
const 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):
Name | Type | Mandatory | Default Value |
---|
column | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | orderByDesc |
---|
linenumbers | true |
---|
|
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:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | query |
---|
linenumbers | true |
---|
|
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. |
|
Name | Type | Mandatory | Default Value |
---|
attributes | String or Array | Y | N |
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:
Type | Description |
---|
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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | selectAttributes (String) |
---|
linenumbers | true |
---|
|
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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | selectAttributes (Array) |
---|
linenumbers | true |
---|
|
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):
Name | Type | Mandatory | Default Value |
---|
flag | Boolean | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setAbortAction |
---|
linenumbers | true |
---|
|
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):
Name | Type | Mandatory | Default Value |
---|
maxNumRecords | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setLimit |
---|
linenumbers | true |
---|
|
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):
Name | Type | Mandatory | Default Value |
---|
property | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setMultipleValue |
---|
linenumbers | true |
---|
|
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)
This method sets the ID of the defined RE model. To get the model ID, use the getReModelId method.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
reModelId | String | Y | N |
If the reModelId parameter is equal to 'null', the REM, related to the record, will be detached.
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getReModelId |
---|
linenumbers | true |
---|
|
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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | setReModelId |
---|
linenumbers | true |
---|
|
(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); |
setValue(property, value)
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setMultipleValue |
---|
linenumbers | true |
---|
|
const task = new SimpleRecord('task');
task.addQuery('state', '7'); // Draft
task.query();
ss.info(task.getRowCount());
task.setMultipleValue('state', '2'); // Open
// task.updateMultiple(); |
setValue(property, value
This method sets the value of the field in the current record.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
property | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|
Void | This property does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setValue |
---|
linenumbers | true |
---|
|
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.
Name | Type | Mandatory | Default Value |
---|
enable | Boolean | N | true |
Type | Description |
---|
Void | This property does not return a value. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | silentMode |
---|
linenumbers | true |
---|
|
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,
|
it is inserted.- the getErrors() method will return this error:
"Unable to update new record. Use `insert()` instead. (record id: )"
|
Return:
Type | Description |
---|
IntegerString | - If validation errors occurred and 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 (inserted) record returns.
|
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | update |
---|
linenumbers | true |
---|
|
const incidentcurrent = new SimpleRecord('itsm_incidentuser');
incidentcurrent.get(record_id(ss.getUserId());
if (incident.sys_id) {
incident.subject += " (repair)";
const updatedID = incident.update();
if (updatedID == 0) {
ss.debug(incidentcurrent.timezone_id = '156076775207670452'; // UTC
ss.info(current.update());
ss.info(current.getErrors());
// Info: }
}155931135900000001
// Info: [] |
updateMultiple()
This method updates all the selection entries.
Return:
Type | Description |
---|
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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | updateMultiple |
---|
linenumbers | true |
---|
|
const task = new SimpleRecord('task');
task.addQuery('state', '0'); // Open
task.query();
ss.info(task.getRowCount());
task.setMultipleValue('state', '10'); // Canceled
// task.updateMultiple(); |