Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This server class provides methods to operate with database records.

initialize()

This method creates an empty object for the new database record.


Return:

TypeDescription
VoidThis method does not return a value


Example:

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


get(propertyOrValue, value)

Loads an object from a database based on the field value, or in a specific case by sys_id.


Parameter(s):

NameType
propertyOrValuename (value must be specified as well).
propertyOrValuemixed
valuemixed


Return:

TypeDescription
voidThis method does not return a value.


Example:

Code Block
languagejs
titleget
let incident = new SimpleRecord("incident");
incident.get( "subject" , "Network does not work" )


addQuery(property, operatorOrValue, value)

Adding a condition for the selection from the database.


Parameter(s):

NameType
propertyString
operatorOrValueChoice (=, Like), etc.
operatorOrValueMixed
valueMixed


Return:

TypeDescription
SimpleRecordAn object that performs request to the method.


Example:

Code Block
languagejs
titleaddQuery
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();


query()

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


Return:

TypeDescription
VoidThis method does not return a value.


next()

Returns next record from the list.


Return:

TypeDescription
Record


Example:

Code Block
languagejs
titlenext
let incident = new SimpleRecord("incident");

incident.query();

while ( incident.next() ){

ss.info( incident.sys_id);

}


getValue(property)


getClassDisplayValue(property)

Returns the table title. If the title is not set, then returns name.


Return:

TypeDescription
StringTitle or name.


Example:

Code Block
languagejs
titlegetClassDisplayValue
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):

NameType
PropertyString


Return:

TypeDescription
MixedA field or record value.


Example:

Code Block
languagejs
titlegetDisplayValue
let incident = new SimpleRecord("incident");

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


getLabel(property)

Returns the field title.


Parameter(s):

NameType
propertyString


Return:

TypeDescription
MixedThe field title.


Example:

Code Block
languagejs
titlegetLabel
let incident = new SimpleRecord("incident");

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


setValue(property, value)

Sets the value of the field in the current record.


Parameter(s):

NameType
propertyString
valueMixed


Return:

TypeDescription
VoidThis property does not returns a value.


Example:

Code Block
languagejs
titlesetValue
let incident = new SimpleRecord('incident');

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

incident.insert();




next()

Описание: Возвращает следующую запись из списка.

Принимает: Ничего.

Возвращает: Record | bool(если новый запрос то возвращает первую или false).

getValue(property)

Описание: Синоним для геттера.

Принимает:string (поле, которое нужно вернуть).

Описание: Устанавливает значение поля в текущей записи.

Возвращает: mixed.

setValue(property, value)

Принимает:property - string, value - mixed.Возвращает: Ничего.

Example:

let incident = new SimpleRecord('incident');

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

incident.insert();

getTableName()

Описание: Возвращает имя текущей таблицы.

Принимает:Ничего.

Возвращает: string.

let incident = new SimpleRecord('incident');

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

insert()

Описание: Создает запись в БД.

Принимает:Ничего.

Возвращает: integer (sys_id созданной записи).

Example:

let incident = new SimpleRecord('incident');

incident.insert();

update(reason)

Описание: Обновляет запись в БД.

Принимает:string (причина обновления).

Возвращает: integer (sys_id обновленной записи).

Example:

let incident = new SimpleRecord('incidnet');

incident.get(5246);

incident.subject += " (repair)";

incident.update();

addEncodedQuery(condition)

Описание: Добавляет закодированный запрос к другим запросам, которые могли быть установлены. (не переносить, работает не верно, необходимо править)

Принимает:string.

Возвращает: Ничего.

deleteRecord(recordSetId)

Описание: Удаляет текущую запись.

Принимает:integer.

Возвращает: bool.

Example:

let incident = new SimpleRecord('incident');

incident.get(5236);

incident.deleteRecord();

deleteMultiple()

Описание: Удаляет несколько записей, которые удовлетворяют условию запроса. Этот метод не удаляет вложения. Не используйте deleteMultiple() для таблиц с зависимыми полями. Всегда удаляйте каждую запись отдельно. Кроме того, не используйте этот метод с методом setLimit() при работе с большими таблицами.

Принимает: ничего.

Возвращает: bool.

Example:

let incident = new SimpleRecord('incident');

incident.addQuery( 'subject' , "LIKE" , "network" );

incident.query();

incident.deleteMultiple();

getCurrentRecord()

Описание: Возвращает текущую запись. (не переносить, внутренний метод)

Принимает:ничего.

Возвращает: Record|false.

orderBy(column)

Описание: Определяет столбец orderBy.
Вызовите этот метод более одного раза, чтобы упорядочить по нескольким столбцам.
Результаты расположены в порядке возрастания, см. OrderByDesc (имя строки), чтобы упорядочить записи в порядке убывания.

Принимает: string.

Возвращает: Ничего.

Example:

let incident = new SimpleRecord('incident');

incident.orderBy('subject');

incident.query();

orderByDesc(column)

Описание: Определяет нисходящий порядок по столбцу.

Принимает: string.

Возвращает: Ничего.

Example:

let incident = new SimpleRecord('incident');

incident.orderByDesc('subject');

incident.query();

setLimit(maxNumRecords)

Описание: Устанавливает ограничение на количество записей, извлекаемых по запросу SimpleRecord.

Принимает: integer.

Возвращает: Ничего.

Example:

let incident = new SimpleRecord('incident');

incident.setLimit(30);

incident.query();

addOrCondition(property, operatorOrValue, value)

Описание: Добавляет условие OR параметра 2 или 3 к существующему запросу. Используется вместе с addQuery.

Принимает: property - string, operatorOrValue - оператор выбора (=, like, etc.) или значение - mixed. Опционально: value - mixed.

Возвращает:объект SimpleRecord, который выполняет обращение к методу.

Example:

let incident = new SimpleRecord('incident');
incident.addQuery( 'contact_type' , 'email' ).addOrCondition( 'number' , 'INC0000006');
incident.query();



Method descrtiption


Parameter(s):

NameType



Return:

TypeDescription



Example:

Code Block


Table of Contents