You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 51 Next »

This server class provides methods to operate with database records.

addOrCondition(property, operatorOrValue, value)

Appends a 2-or-3 parameter OR condition to an existing query. Works in conjunction with any of the addQuery() methods.


Parameter(s):

NameTypeMandatoryDefault Value
propertyString

operatorOrValueChoice (=, Like), etc.

operatorOrValueMixed

valueMixed


Return:

TypeDescription
SimpleRecordAn object that performs request to the method.


Example:

addOrCondition
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):

NameTypeMandatoryDefault Value
propertyString

operatorOrValueChoice (=, Like), etc.

operatorOrValueMixed

valueMixed


Return:

TypeDescription
SimpleRecordAn object that performs request to the method.


Example:

addQuery
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()

Determines if the Access Control Rules permit inserting new records in this table.


Return:

TypeDescription
BooleanTrue if permitted; otherwise returns false.


Example:

canCreate
let incident = new SimpleRecord('incident');
ss.info( incident.canCreate() );

canDelete()

Determines if the Access Control Rules permit deleting records in this table.


Return:

TypeDescription
BooleanTrue if permitted; otherwise returns false.


Example:

canDelete
let incident = new SimpleRecord('incident');
ss.info( incident.canDelete() );

canRead()

Determines if the Access Control Rules permit reading records in this table.


Return:

TypeDescription
BooleanTrue if permitted; otherwise returns false.


Example:

canRead
let incident = new SimpleRecord('incident');
ss.info( incident.canRead() );

canUpdate()

Determines if the Access Control Rules permit updating records in this table.


Return:

TypeDescription
BooleanTrue if permitted; otherwise returns false.


Example:

canUpdate
let incident = new SimpleRecord('incident');
ss.info( incident.canUpdate() );


deleteMultiple()

This method allows to delete multiple records that meet the query condition.

It does not allow to delete attachments.

Do not use it on tables with dependencies. Always delete every record individually.

Also, 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:

TypeDescription
BooleanTrue if deleted successfully; otherwise returns false.


Example:

deleteMultiple
let incident = new SimpleRecord('incident');
incident.addQuery( 'subject' , "LIKE" , "network" );
incident.query();
incident.deleteMultiple();

deleteRecord(recordSetId)

Deletes the current record.


Parameter(s):

NameTypeMandatoryDefault Value
recordSetIdInteger


Return:

TypeDescription
BooleanTrue if deleted successfully; otherwise returns false.


Example:

deleteRecord
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):

NameTypeMandatoryDefault Value
propertyOrValuename (value must be specified as well).

propertyOrValuemixed

valuemixed


Return:

TypeDescription
voidThis method does not return a value.


Example:

get
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:

TypeDescription
StringTitle or name.


Example:

getClassDisplayValue
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):

NameTypeMandatoryDefault Value
PropertyString


Return:

TypeDescription
MixedA field or record value.


Example:

getDisplayValue
let incident = new SimpleRecord("incident");

incident.get(5236);
ss.info( incident.getDisplayValue( "caller_id" ) );

getLabel(property)

Returns the field title.


Parameter(s):

NameTypeMandatoryDefault Value
propertyString


Return:

TypeDescription
MixedThe field title.


Example:

getLabel
let incident = new SimpleRecord("incident");

incident.get(5236);
ss.info( incident.getLabel( "caller_id" ) );

getTableName()

Returns the current table name.


Return:

TypeDescription
StringThe current table name.


Example:

getTableName
let incident = new SimpleRecord('incident');

ss.info( incident.getTableName() ); // incident

getValue(property)

Returns the value of the object property based on its name.

Parameter(s):

NameTypeMandatoryDefault Value
PropertyString


Return:

TypeDescription
MixedThe value of the field.


getValue
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:

TypeDescription
VoidThis method does not return a value


Example:

initialize
let incident = new SimpleRecord("incident");
incident.initialize();
incident.subject = "Network does not work";
incident.insert();

insert()

Creates a database record.


Return:

TypeDescription
IntegerSys_id of the record created.


Example:

insert
let incident = new SimpleRecord('incident');

incident.insert();

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:

next
let incident = new SimpleRecord("incident");

incident.query();

while ( incident.next() ){

ss.info( incident.sys_id);

}

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):

NameTypeMandatoryDefault Value
StringColumn name.


Return:

TypeDescription
VoidThis method does not return a value.


Example:

orderBy
let incident = new SimpleRecord('incident');
incident.orderBy('subject');
incident.query();

orderByDesc(column)

Sorts the records in the descending order.


Parameter(s):

NameTypeMandatoryDefault Value
StringColumn name.


Return:

TypeDescription
VoidThis method does not return a value.


Example:

orderByDesc
let incident = new SimpleRecord('incident');
incident.orderByDesc('subject');
incident.query();

query()

Runs a query against the selection from the database based on the $this→query. Fills in the record set.

Return:

TypeDescriptionMandatoryDefault Value
VoidThis method does not return a value.


setAbortAction(flag)

Sets a flag indicating that will be current operation (insert/update/delete) interrupted. Used in business-rules.

NameType
flagBoolean


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setAbortAction
current.setAbortAction(true);

setLimit(maxNumRecords)

Sets a limit for a number of records are fetched by SimpleRecord query.


Parameter(s):

NameTypeMandatoryDefault Value
maxNumRecordsInteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setLimit
let incident = new SimpleRecord('incident');
incident.setLimit(30);
incident.query();

setValue(property, value)

Sets the value of the field in the current record.


Parameter(s):

NameTypeMandatoryDefault Value
propertyString

valueMixed


Return:

TypeDescription
VoidThis property does not returns a value.


Example:

setValue
let incident = new SimpleRecord('incident');

incident.setValue("subject" , "Help me");

incident.insert();

update(reason)

Updates a database record


Parameter(s):

NameTypeMandatoryDefault Value
StringReason of the update


Return:

TypeDescription
IntegerSys_id of the updated record.


Example:

update
let incident = new SimpleRecord('incidnet');
incident.get(5246);
incident.subject += " (repair)";
incident.update();


  • No labels