This server class provides methods to operate with database records.
addOrCondition(property, operatorOrValue, value)
Описание: Добавляет условие OR параметра 2 или 3 к существующему запросу. Используется вместе с addQuery.
Parameter(s):
Name | Type |
---|---|
property | String |
operatorOrValue | Choice (=, Like), etc. |
operatorOrValue | Mixed |
value | Mixed |
Return:
Type | Description |
---|---|
SimpleRecord | An object that performs request to the method. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.addQuery( 'contact_type' , 'email' ).addOrCondition( 'number' , 'INC0000006'); incident.query(); |
addQuery(property, operatorOrValue, value)
Adding a condition for the selection from the database.
Parameter(s):
Name | Type |
---|---|
property | String |
operatorOrValue | Choice (=, Like), etc. |
operatorOrValue | Mixed |
value | Mixed |
Return:
Type | Description |
---|---|
SimpleRecord | An object that performs request to the method. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord("incident"); incident.addQuery( "active", true ); incident.addQuery( "subject" , "LIKE" , "сеть" ); incident.addQuery( "sys_created_at" , "<" , "2019-04-01 00:00:00" ); incident.query(); |
deleteMultiple()
This method allows to delete multiple records that satisfy the query condition.
It does not allow to delete attachments.
Do not use it on tables with dependencies. Always delete every record individually.
Alsp, do not use it combined with the setLimit() method when working with large tables.
Do not use deleteMultiple() on tables with currency fields. Always delete each record individually. Also, do not use this method with the chooseWindow() or setLimit() methods when working with large tables.
Return:
Type | Description |
---|---|
Boolean |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.addQuery( 'subject' , "LIKE" , "network" ); incident.query(); incident.deleteMultiple(); |
deleteRecord(recordSetId)
Deletes the current record.
Parameter(s):
Name | Type |
---|---|
recordSetId | Integer |
Return:
Type | Description |
---|---|
Boolean |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.get(5236); incident.deleteRecord(); |
get(propertyOrValue, value)
Loads an object from a database based on the field value, or in a specific case by sys_id.
Parameter(s):
Name | Type |
---|---|
propertyOrValue | name (value must be specified as well). |
propertyOrValue | mixed |
value | mixed |
Return:
Type | Description |
---|---|
void | This method does not return a value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord("incident"); incident.get( "subject" , "Network does not work" ) |
getClassDisplayValue(property)
Returns the table title. If the title is not set, then returns name.
Return:
Type | Description |
---|---|
String | Title or name. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord("incident"); ss.info( incident.getClassDisplayValue() ); |
getDisplayValue(property)
Returns a displayed field or record value ('display_by_ref' field).
For example, for the 'reference' field entity name will be returned, not an ID.
Parameter(s):
Name | Type |
---|---|
Property | String |
Return:
Type | Description |
---|---|
Mixed | A field or record value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord("incident"); incident.get(5236); ss.info( incident.getDisplayValue( "caller_id" ) ); |
getLabel(property)
Returns the field title.
Parameter(s):
Name | Type |
---|---|
property | String |
Return:
Type | Description |
---|---|
Mixed | The field title. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord("incident"); incident.get(5236); ss.info( incident.getLabel( "caller_id" ) ); |
getTableName()
Returns the current table name.
Return:
Type | Description |
---|---|
String | The current table name. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); ss.info( incident.getTableName() ); // incident |
getValue(property)
Описание: Синоним для геттера.
Принимает:string (поле, которое нужно вернуть).
Возвращает: mixed.
initialize()
This method creates an empty object for the new database record.
Return:
Type | Description |
---|---|
Void | This method does not return a value |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord("incident"); incident.initialize(); incident.subject = "Network does not work"; incident.insert(); |
insert()
Creates a database record.
Return:
Type | Description |
---|---|
Integer | Sys_id of the record created. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident');
incident.insert(); |
query()
Runs a query against the selection from the database based on the $this→query. Fills in the record set.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
next()
If a new request, then returns the first record from the list; otherwise returns false, in case if the record is unavailable.
Return:
Type |
---|
Record or Boolean |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord("incident"); incident.query(); while ( incident.next() ){ ss.info( incident.sys_id); } |
setValue(property, value)
Sets the value of the field in the current record.
Parameter(s):
Name | Type |
---|---|
property | String |
value | Mixed |
Return:
Type | Description |
---|---|
Void | This property does not returns a value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident');
incident.setValue("subject" , "Help me");
incident.insert(); |
insert()
Creates a database record.
Return:
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident');
incident.insert(); |
update(reason)
Updates a database record
Parameter(s):
Name | Type |
---|---|
String | Reason of the update |
Return:
Type | Description |
---|---|
Integer | Sys_id of the updated record. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incidnet'); incident.get(5246); incident.subject += " (repair)"; incident.update(); |
orderBy(column)
Specifies an orderBy column.
Call this method several times to order by multiple columns.
Results are arranged in ascending order. To arrange the records in descending order use orderByDesc method.
Parameter(s):
Name | Type |
---|---|
String | Column name. |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.orderBy('subject'); incident.query(); |
orderByDesc(column)
Sorts the records in the descending order.
Parameter(s):
Name | Type |
---|---|
String | Column name. |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.orderByDesc('subject'); incident.query(); |
setLimit(maxNumRecords)
Sets a limit for a number of records are fetched by SimpleRecord query.
Parameter(s):
Name | Type |
---|---|
Integer | The limit value. |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.setLimit(30); incident.query(); |
Table of Contents |
---|