Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
This server class provides methods to operate with database records.
addOrCondition(property, operatorOrValue, 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.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
property | String | Y | N |
operatorOrValue | Choice (=, Like), etc. | Y | N |
operatorOrValue | Mixed | Y | N |
value | Mixed | N | NULL |
Return:
Type | Description |
---|---|
SimpleRecord | An object performing the 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)
This method adds a condition for the selection from the database.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
property | String | Y | N |
operatorOrValue | Choice (=, Like), etc. | Y | N |
operatorOrValue | Mixed | Y | N |
value | Mixed | N | NULL |
Return:
Type | Description |
---|---|
SimpleRecord | An object performing the 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(); |
canCreate()
This method determines if the Access Control Rules permit inserting new records in this table.
Return:
Type | Description |
---|---|
Boolean | The method returns TRUE if this operation is permitted; otherwise it returns FALSE. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); ss.info( incident.canCreate() ); |
canDelete()
This method determines if the Access Control Rules permit deleting records in this table.
Return:
Type | Description |
---|---|
Boolean | The method returns TRUE if this operation is permitted; otherwise it returns FALSE. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); ss.info( incident.canDelete() ); |
canRead()
This method determines if the Access Control Rules permit reading records in this table.
Return:
Type | Description |
---|---|
Boolean | The method returns TRUE if this operation is permitted; otherwise it returns FALSE. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); ss.info( incident.canRead() ); |
canUpdate()
This method determines if the Access Control Rules permit updating records in this table.
Return:
Type | Description |
---|---|
Boolean | The method returns TRUE if this operation is permitted; otherwise it returns FALSE. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); ss.info( incident.canUpdate() ); |
deleteMultiple()
This method allows deleting multiple records that meet the query condition. It does not allow deleting attachments.
Do not use it on tables with dependencies. Always delete each record individually.
Also, do not use it combined with the setLimit() method when working with large tables.
Do not use the deleteMultiple() method on the tables with the 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 | This method returns TRUE if deleted successfully; otherwise returns false. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.addQuery( 'subject' , "LIKE" , "network" ); incident.query(); incident.deleteMultiple(); |
deleteRecord(recordSetId)
Deletes This method deletes the current record.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
recordSetId | Integer | N | -1 |
Return:
Type | Description |
---|---|
Boolean | True if This method returns TRUE if the record is deleted successfully; otherwise it returns falseFALSE. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.get(5236); incident.deleteRecord(); |
get(propertyOrValue, value)
Loads This method loads an object from a database based on the field value, or, in a specific case, by the sys_id.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
propertyOrValue | name (value must be specified as well). | Y | N |
propertyOrValue | mixed | Y | N |
value | mixed | N | NULL |
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()
Returns This method 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 This method returns displayed field or record value ('the display_by_ref' field).For For example, for the 'reference' reference field the entity name will be returned, but not an the ID.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
Property | String | N | NULL |
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" ) ); |
getErrors()
If the record createcreating, update updating or delete deleting will fail, then this method will display error message.
Return:
Type | Description |
---|---|
Array | The error value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let rec = new SimpleRecord('sys_db_table'); rec.get('name', 'task'); if (!rec.deleteRecord()) { let errors = rec.getErrors(); errors.forEach(function(error) { ss.addErrorMessage(error); }) } |
getLabel(property)
Returns This method returns the field title.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
property | String | Y | N |
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 This method 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)
Returns This method returns the value of the object property based on its name.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
Property | String | Y | N |
Return:
Type | Description |
---|---|
Mixed | The value of the field. |
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.query(); while( incident.next() ){ ss.info( incident.getValue('number') ); } |
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 This method creates a database record.
Return:
Type | Description |
---|---|
Integer | The Sys_id of the record created. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.insert(); |
next()
If this is a new request, then this method returns the first record from the list; otherwise it returns falseFALSE, in the 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); } |
orderBy(column)
Specifies This method specifies an orderBy column.
Call this method several times to order by multiple columns.
Results The results are arranged in ascending order. To arrange the records in descending order, use the orderByDesc method.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
column | StringColumn name. | Y | N |
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 This method sorts the records in the descending order.
Parameter(s):
Name | Type | Mandatory | Default Value | |
---|---|---|---|---|
column | String | Column name. | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.orderByDesc('subject'); incident.query(); |
query()
Runs This method runs a query against the selection from the database, based on the $this→query. Fills After this, it fills in the record set.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
setAbortAction(flag)
Sets This method sets a flag, indicating that will be current operation (insert/update/delete) interrupted. Used It used in business-rules.
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 | ||||
---|---|---|---|---|
| ||||
current.setAbortAction(true); |
setLimit(maxNumRecords)
Sets a limit for a number of records are fetched by SimpleRecord query.
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 | ||||
---|---|---|---|---|
| ||||
let incident = new SimpleRecord('incident'); incident.setLimit(30); incident.query(); |
setValue(property, value)
Sets This method sets the value of the field in the current record.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
property | String | Y | N |
value | Mixed | Y | N |
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(); |
update(reason)
Updates This method updates a database record.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
reason | String | N | '' |
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(); |
Table of Contents | ||||
---|---|---|---|---|
|