Model class
This functionality is available for Creatio 8.2.2 and later, Mobile Creatio 8.2.6 and later.
The Model
class implements a data model to execute operations with data source records.
Methods
load()
Retrieves a record from a data source. A configuration object is a key-value collection.
Parameters
attributes
Specifies record columns to retrieve from the data source. The attributes
property limits the retrieved data, which, in turn, improves performance and reduces unnecessary data transfer.
parameters
An array of query filters. type The parameter type. The value The To retrieve a dedicated record, set the Parameters
ModelParameterType.Filter
value marks the parameter as a query filter.BaseFilter
class instance that limits the retrieved data using the specified condition.ModelParameterType.PrimaryColumnValue
value to the type
parameter and record ID to the value
parameter.const result = await model.load({
attributes: ['Name'],
parameters: [{
type: ModelParameterType.PrimaryColumnValue,
value: 'd4f93b6c-362c-4954-8bd6-1658e9206d4e'
}]
});
loadOptions
Additional properties required to set up pagination, sorting and caching. pagingConfig Sets up pagination that controls rows of data to retrieve at once. rowsOffset An initial position (offset) to load the first portion of data. If you omit the property, Creatio sets the offset to "0." rowCount The number of records to upload to the page. sortingConfig Sets up sorting of retrieved data. columns Specifies the initial data sorting settings. columnName Name of the column by which to sort data. direction Sorting order. asc Ascending. desc Descending. cacheOperation Manages caching of data retrieved from the data source. updateCache The flag that specifies whether the true Mobile Creatio retrieves data from the server and caches retrieved data. Mobile Creatio omits the false Mobile Creatio works with data directly from the cache, omitting the data source. This accelerates data retrieval. Mobile Creatio omits the readCacheMode Sets up how to retrieve data from the cache. By default, ReadCacheMode.Auto Mobile Creatio can retrieve data from the cache or directly from the data source based on the values of the Mobile application operation mode ( ReadCacheMode.ForceLocal Mobile Creatio retrieves data from the cache and omits updates in the data source. This is useful if you work in the offline mode or if you want to work with cached data only. ReadCacheMode.ForceRemote Mobile Creatio retrieves data directly from the data source, omitting the cache. This is useful if you want to work with up-to-date data only. cacheDataType Determines whether to load records fully and set all columns required in the app. By default, CacheDataType.Partial Stores only a portion of data in the cache. It is used to load data collection. CacheDataType.Full Stores the data in the cache entirely. It is used to load a single record. When you use the syncRuleName Sets up a rule to synchronize the cache.Parameters
Parameters
Parameters
Parameters
Available values
Parameters
load()
operation must retrieve data from the server and write it to the cache. By default, true
.Available values
updateCache: true
parameter value in the following cases:
readCacheMode
parameter is set to ReadCacheMode.ForceLocal
.MobileApplicationMode
code) system setting is set to "offline" and the EnableMobileDataAutoSynchronization
additional feature is disabled.updateCache: false
parameter value in the following cases:
readCacheMode
parameter is set to ReadCacheMode.ForceRemote
.ReadCacheMode.Auto
.Available values
MobileApplicationMode
code) system setting and updateCache
parameter. We recommend using the ReadCacheMode.Auto
value regardless of the Mobile application operation mode (MobileApplicationMode
code) system setting value.CacheDataType.Partial
.Available values
CacheDataType.Full
parameter value, make sure that all required columns are set to the attributes
parameter.
insert()
Adds a record to a data source. A configuration object is a key-value collection.
Parameters
cacheOperation
Manages caching of data added to the data source. updateCache The flag that specifies whether the true Mobile Creatio caches added data. Mobile Creatio omits the false Mobile Creatio works with data directly from the cache, omitting the data source.Parameters
insert()
operation must retrieve data from the server and write it to the cache. By default, true
.Available values
updateCache: true
parameter value when the EnableMobileDataAutoSynchronization
additional feature is enabled.
copy()
Copies the original record from a data source. To add a new record, use the model.insert()
method. Specify record ID that identifies a record to copy from the data source and a list of modified values for a new record.
update()
Modifies a record in a data source. A configuration object is a key-value collection.
Parameters
{DataSourceParameters}
An array of parameters that identify a record to modify. type The parameter type. The value The record ID.Parameters
ModelParameterType.PrimaryColumnValue
value marks the parameter as a record ID.
cacheOperation
Manages caching of data modified in the data source. updateCache The flag that specifies whether the true Mobile Creatio caches modified data. Mobile Creatio omits the false Mobile Creatio works with data directly from the cache, omitting the data source.Parameters
update()
operation must retrieve data from the server and write it to the cache. By default, true
.Available values
updateCache: true
parameter value when the EnableMobileDataAutoSynchronization
additional feature is enabled.
delete()
Deletes a record from a data source. A configuration object is a key-value collection.
Parameters
{DataSourceParameters}
An array of parameters that identify a record to delete. type The parameter type. The value The record ID.Parameters
ModelParameterType.PrimaryColumnValue
value marks the parameter as a record ID.
cacheOperation
Manages caching of data deleted from the data source. updateCache The flag that specifies whether the true Mobile Creatio caches deleted data. Mobile Creatio omits the false Mobile Creatio works with data directly from the cache, omitting the data source.Parameters
delete()
operation must retrieve data from the server and write it to the cache. By default, true
.Available values
updateCache: true
parameter value when the EnableMobileDataAutoSynchronization
additional feature is enabled.