...
Tip |
---|
Role required: admin. |
...
...
...
...
...
...
...
...
Recommendations
...
...
The example below generates an array containing IDs of the records:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
const user = new SimpleRecord('user');
user.addQuery('email', 'like', 'best.company');
user.getAttributes('sys_id'); // выбираем только sys_id
user.query();
const userIDs = [];
while (user.next()) {
userIDs.push(user.sys_id);
}
|
Comment your code when you use the Choice attributes in your scripts:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
if (current.stage == '4' || current.stage == '6') { //Canceled OR Completed
const start = new SimpleDateTime(current.start_time);
//...
|
Use the getAttributes() method to check an object before inserting or updating:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
const task = new SimpleRecord('task');
task.initialize();
ss.info(task.getAttributes());
// Info: {"sys_id":"","parent_id":"","assigned_user":"","number":"","short_description":"","active":1,"comments":"","description":"","state":7,"priority":"","urgency":"","impact":"","escalation":"","opened_at":"2020-07-24 08:55:33", ...}
|
Also, this method allows checking whether an object has a specified attribute or not before calling:
...
language | js |
---|---|
theme | Eclipse |
linenumbers | true |
...