The Creatio DataService web service is a RESTfull service. RESTful is a quite simple information management interface that doesn't use any additional internal layers, i.e., the data doesn't need to be converted to any third-party format, such as XML. In a simple RESTful service, each record is uniquely identified by a global identifier such as URL. Each URL, in turn, has a strictly specified format. However, this service is not always convenient for transferring large amounts of data.
With the use of the DataService, the data can be automatically configured in various data formats such as XML, JSON, HTML, CSV, and JSV. The data structure is determined by data contracts.
The full list and description of the DataService data contracts is displayed on table.
Service | Description |
---|---|
InsertQuery | Add section record query class. |
UpdateQuery | Update section record query class. |
DeleteQuery | Delete section record query class. |
SelectQuery | Select section record query class. |
BatchQuery | Package query class. |
Filters | Filter class. |
Restrictions when using DataService
When using DataService, take into account the following restrictions:
- Maximum number of records that you can obtain by request is specified in the MaxEntityRowCount (the default value is 20000). You can change the system setting value in the .\Terrasoft.WebApp\Web.config file.
- The number of requests is unlimited.
Example implementation algorithm
1. Add button to the Contacts section
For this particular case, you need to create a replacement client module of the Contacts section.
In the created client schema, add the InsertQueryContactButtonCaption localizable string, and set the "Add contact" value to it.
Add a configuration object with the button location settings to the diff array.
2. Add the processing method for the button click event
In order for a record with the necessary data to be added when a button created in the section is clicked, add the following method to the methods section of the replacement client schema:
The implementation of the InsertQuery class for the client part of the application kernel is different from the implementation of the InsertQuery in its back end. So, to create the parameters, the setParameterValue method is used, and for the query execution — the execute method. Learn about all the available properties and methods of the InsertQuery class implemented in the kernel client part in the API documentation.
Example implementation algorithm
1. Add a button in the Contacts section
Create a replacing client module of the Contacts section.
In the created client schema, add SelectQueryContactButtonCaption localizable string and set its value to Select contacts.
Add a configuration object with the settings determining the button position to the diff array.
2. Add handler method for the button pressing event
To enable reading the records when the button is clicked, add the following method to the methods section of the replacing client schema:
In the client of the application core, there is not a class like the server core SelectQuery class. To select data from a section, use the Terrasoft.EntitySchemaQuery class. For more information on this class methods and properties are described in the API documentation.
Example implementation algorithm
1. Create and configure a C# console application project that reads records
To perform this step, you must perform the example of reading records in a third-party application.
The result of the query class implementation instance to read the records with the columns in an abbreviated form:
2. Add filter implementation
In order to filter data, you must create an instance of the Filters collection class instance, fill in the necessary properties, and then pass the link to this instance to the Filters property of the query class instance that you created in the previous step.
The Items property must contain the key-value type collection. The key is a string containing the filter name, and the value is an instance of the Filter class that contains a direct implementation of the filter.
To implement a filter that selects only those contacts that have a number of activities within a range of 1 to 3, you must add the following instance to the collection of filters:
Add the following instance to the filter collection to filter contact records where the Full name column value begins with "H":
Example implementation algorithm
1. Create and set up a C# application project that reads records
To execute this step, execute the record reading example.
The result of implementing an instance of query class for reading records:
2. Add a filter implementation with macros
To filter the data, create an instance of the Filters collection class, fill out the properties with corresponding values, and then pass the instance link to the Filters property of the query class created on the previous step.
The collection contains a single filter with the FilterYear key. Because only those records that have their year of birth equal to 1992 must be selected from the collection, the type of filter is set as a comparison filter. The type of comparison is set as an equality of values. As a verified expression, set the Date of birth column. Specify the macro function as the expression to compare with.
In this case using a macro is optimal because the birth date is stored in the database in YYYY-MM-DD format. The macro automatically determines the year value, so the developer does not need to write additional program code.
Because the EntitySchemaQueryMacrosType.Year macro is parametric, the FunctionArgument property must be initialized and assigned a link to an instance of the BaseExpressionclass. In it, the integer parameter with value "1992" is defined.
Example implementation algorithm
1. Create and set up a C# application project
Using the Microsoft Visual Studio development environment (version 2017 and up), create a Visual C# console application project and specify project name, for example, DataServiceUpdateExample. Set ".NET Framework 4.7" for the project property Target framework.
In the References section of the project, add dependencies from the following libraries:
- System.Web.Extensions.dll – class library included in .NET Framework;
- Terrasoft.Core.dll – library of base Creatio server core classes. It can be found using the following path: [Creatio setup catalog]\Terrasoft.WebApp\bin\Terrasoft.Core.dll;
- Terrasoft.Nui.ServiceModel.dll — application service class library. It can be found using the following path: [Creatio setup catalog]\Terrasoft.WebApp\bin\Terrasoft.Nui.ServiceModel.dll;
- Terrasoft.Common.dll – library of base Creatio server core classes. It can be found using the following path: [Creatio setup catalog]\Terrasoft.WebApp\bin\Terrasoft.Common.dll.
Add the using directives to the application source code file:
2. Add fields and constants and field declarations to the source code
To access DataService features, add the fields and constants to the application source code.
Here, three string fields are declared. These fields will be used to form authentication query and read data queries execution paths. Authentication data will be saved in the AuthCookie field.
3. Add method that performs Creatio application authentication
Authentication is required to enable access to the DataService for the created application.
4. Add implementation of the record add query
Because the updateQueryUri constant declared earlier contains a path for sending data in the JSON format, sent data must be configured beforehand as a string that contains a JSON object that corresponds to the UpdateQuery data contract. This can be done directly in a string variable, although a much more secure and convenient way of doing this would be to create an instance of the UpdateQuery class, fill out its properties and then serialize it to a string.
Here, an instance of the UpdateQuery class is created. In the ColumnValues property, the "j.smith@creatio.com" value is set for the Email column. To apply this value to a specific record or group of records, specify a link to a correctly initialized Filters class in the Filters property. In this case, a single filter is added to the filters collection to select only records that have the "John Smith" value in the Full name column.
The next step is to execute DataService POST-query. To do this, create an instance of the <HttpWebRequest class, fill its properties and connect the string with the JSON object created earlier then execute the DataService query and process its result. To do this, add the following source code:
Example implementation algorithm
1. Create and configure a C# console application project
Using the Microsoft Visual Studio (version 2017 and up) development environment, create a Visual C# console application project and name it DataServiceDeleteExample. The Target framework project property must be set to .NET Framework 4.7.
In the References section of the project you need to add dependencies of the following libraries:
- System.Web.Extensions.dll is a class library included in the .NET Framework
- Terrasoft.Core.dll is a main class library of the application server kernel. Can be found by the following path: [Directory with the installed application]\Terrasoft.WebApp\bin\Terrasoft.Core.dll
- Terrasoft.Nui.ServiceModel.dll class library the application services. Can be found by the following path: [Directory with the application installed]\Terrasoft.WebApp\bin\Terrasoft.Nui.ServiceModel.dll.
- Terrasoft.Common.dll is a main class library of the application server kernel. Can be found by the following path: [Directory with the installed application]\Terrasoft.WebApp\bin\Terrasoft.Common.dll.
Add using directives to the application source code file:
2. Add field declarations and constants to the application source code
To access the DataService features, you must add the fields and constants to the application source code.
Three string constant fields that are used to carry out the authentication requests and requests to read data are declared here. The authentication data will be stored in the AuthCookie field.
3. Add a method that performs authentication in the Creatio application
You need to authenticate the newly created application to access the DataService web service.
4. Implement a query to add a record
As the previously declared updateQueryUri constant contains the path for sending data in JSON format, the data sent must be pre-configured in the form of a string containing a description of the JSON object corresponding to the UpdateQuery data contract. This can be done directly in a lowercase variable but it is much easier and safer to create an instance of the UpdateQuery class, fill its properties, and then serialize it to a string.
This creates an instance of the DeleteQuery class. The Contact value is set in the RootSchemaName property. To delete a particular record or group of records, you need to set a link to the correctly initialized Filters class instance to the Filters property. In this case, a single filter that selects only records with the John Best value in the Full name column is added to the filter collection.
In the final step you must perform POST query to the DataService service. To do this, create an instance of the HttpWebRequest class, fill in its properties, attach a previously created string with the JSON object to a request, and then execute and process the result of the query to the DataService service. To do this, add the following source code:
Example implementation algorithm
1. Create and set up a C# application project
Using the Microsoft Visual Studio development environment (version 2017 and up), create a Visual C# console application project and specify the project name, for example, DataServiceBatchExample. Set ".NET Framework 4.7" for the project property Target framework.
In the References section of the project, add dependencies from the following libraries:
- System.Web.Extensions.dll – class library included in .NET Framework;
- Terrasoft.Core.dll – library of base Creatio server core classes. It can be found using the following path: [Creatio setup catalog]\Terrasoft.WebApp\bin\Terrasoft.Core.dll;
- Terrasoft.Nui.ServiceModel.dll — application service class library. It can be found using the following path: [Creatio setup catalog]\Terrasoft.WebApp\bin\Terrasoft.Nui.ServiceModel.dll;
- Terrasoft.Common.dll – library of base Creatio server core classes. It can be found using the following path: [Creatio setup catalog]\Terrasoft.WebApp\bin\Terrasoft.Common.dll.
Add the using directives to the application source code file.
2. Add fields and constants and field declarations to the source code
To access DataService features, add the fields and constants to the application source code.
Here, three string fields are declared. These fields will be used to form authentication query and read data queries execution paths. Authentication data will be saved in the AuthCookie field.
3. Add method that performs Creatio application authentication
Authentication is required to enable access of the created application to the DataService.
4. Implement query adding request
Because the batchQueryUri constant declared previously earlier contains a path for sending data in the JSON format, sent data must be configured beforehand as a string that contains a JSON object description. Use data contract classes to create separate queries then serialize them in a string.
For a query to add a contact record with the name "John Smith", add the following program code:
To change the value of the Business phone column to 012 345 67 89 for all contact records that have "John Smith" value in the Full name column, add the code.
After serializing the created instances of the query class, add information about the qualified name of the corresponding data contract to the strings with JSON objects. Compose the string with batch query.
The next step is to execute the POST DataService query. To do this, create an instance of the HttpWebRequest class, fill its properties and connect the string with JSON object, created earlier, then execute the DataService query and process its result. To do this, add the source code.
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The InsertQuery data contract is used to add records to sections. The data is transferred to the DataService via HTTP by using the POST request with the URL.
The InsertQuery data contract has a hierarchical structure with multiple nesting levels. In the Creatio application server part, the InsertQuery data contract is represented by the InsertQuery class of the Terrasoft.Nui.ServiceModel.DataContract namespace of the Terrasoft.Nui.ServiceModel.dll class library. However, for simplicity, the hierarchical structure of the InsertQuery data contract is conveniently presented as a JSON format object:
Properties
A string containing the name of the root object schema of the added record.
Operation type is set by the QueryOperationType namespace Terrasoft.Nui.ServiceModel.DataContract namespace enumeration value. For the InsertQuery the QueryOperationType.Insert value is set.
Select | 0 |
Insert | 1 |
Update | 2 |
Delete | 3 |
Batch | 4 |
Contains a collection of column values of the added record. Its ColumnValues type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.<
The ColumnValues class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The ColumnValues class has a single Items property that is defined as a collection of the Dictionary<string, ColumnExpression> keys and values. The key is a string with the added column title, and the value is the object with the ColumnExpression type defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. The basic properties of the ColumnExpression class used when adding records, are given in table.
Properties
The expression type that defines the value that will be contained in the added column. Set by the EntitySchemaQueryExpressionType enumeration of the Terrasoft.Core.Entities namespace defined in the Terrasoft.Core class library. For the InsertQuery the EntitySchemaQueryExpressionType.Parameter value is set.
SchemaColumn | 0 | Schema column. |
Function | 1 | Function. |
Parameter | 2 | Parameter. |
SubQuery | 3 | Subquery. |
ArithmeticOperation | 4 | Arithmetic operation. |
Defines the value that will be contained in the added column. Its Parameter type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
The Parameter class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The Parameter class has multiple properties, two of which are used to add records.
Properties
The data value type that defines the value that will be contained in the added column. Set by the DataValueType enumeration value of the Terrasoft.Nui.ServiceModel.DataContract namespace.
Guid | 0 |
Text | 1 |
Integer | 4 |
Float | 5 |
Money | 6 |
DateTime | 7 |
Date | 8 |
Time | 9 |
Lookup | 10 |
Enum | 11 |
Boolean | 12 |
Blob | 13 |
Image | 14 |
ImageLookup | 16 |
Mapping | 18 |
The object that contains the added column value.
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The SelectQuery data contract is used for reading section records. The query data is transferred to DataService via HTTP, with the help of POST by the URL.
The SelectQuery data contract has a complex hierarchical structure with a number of nesting levels. In the Creatio server core, it is represented by a SelectQuery class of the Terrasoft.Nui.ServiceModel.DataContract namespace of the Terrasoft.Nui.ServiceModel.dll library of classes. The hierarchical data structure of the SelectQuery data contract can be conveniently viewed in JSON format:
Properties
String that contains root schema name of the added record object.
Type of write operation. Specified as a QueryOperationType enumeration value of the Terrasoft.Nui.ServiceModel.DataContract namespace. The QueryOperationType.Select value is set for SelectQuery.
Select | 0 |
Insert | 1 |
Update | 2 |
Delete | 3 |
Batch | 4 |
Contains a collection of the record columns being read. It has the SelectQueryColumns type defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. It must be configured if the AllColumns checkbox is set to false and a set of specific root schema columns, which does not include the Id column, is required.
Indicates if all columns are selected. If the value is set to true, all columns of the root schema will be selected by the query.
Parameters of EntitySchemaQuery caching on server. The ServerESQCacheParameters type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
Indicates whether the data is selected page-by-page.<
Indicates whether duplicates must be eliminated in the resulting data set.
Number of selected strings. By default, the value is -1, i.e. all strings are selected.
Conditions of creating a page-by-page query. The ColumnValues type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
Indicates whether the data is selected hierarchically.
Maximum nesting level of a hierarchical query.
Name of the column used for creating a hierarchical query.
Initial value of hierarchical column from which the hierarchy will be built.
Collection of query filters. The Filters type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
Contains collection of column values for the added record. The ColumnValues type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
The SelectQueryColumns class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The SelectQueryColumns class has a single Items property, defined as a collection of keys and values Dictionary<string, SelectQueryColumn>. The key is the string with the name of the added column. The value is an instance of the SelectQueryColumn class, defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. The properties of the SelectQueryColumn are available in the table.
Properties
Sorting order. Specified with a value from the OrderDirection enumeration of the Terrasoft.Common name space defined in the Terrasoft.Common class library.
Sets position number in the collection of the query columns, by which the sorting is done.
Column title.
Property that defines expression of the type of selected column.
The ColumnExpression class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The ColumnExpression class defines expression that sets the type of the schema column. The class is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace of the Terrasoft.Nui.ServiceModel library. The properties of an instance of this class are filled in depending on the ExpressionType property, which sets the expression type. The full list of the ColumnExpression class properties is available in table.
Properties
Type of expression that determines the value that the added column will contain. Specified with a value from the ntitySchemaQueryExpressionType enumeration of the Terrasoft.Core.Entities namespace defined in the Terrasoft.Core class library. The EntitySchemaQueryExpressionType.Parameter value is set for InsertQuery.
SchemaColumn | 0 | Schema column. |
Function | 1 | Function. |
Parameter | 2 | Parameter. |
SubQuery | 3 | Subquery. |
ArithmeticOperation | 4 | Arithmetic operation. |
Path to the column in relation to the root schema. Rules for building paths are available in the Build path to columns article.
Determines the value that the added column will contain. The Parameter type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
Function type. Specified with a value from the FunctionType enumeration, which is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
None | 0 | Not defined. |
Macros | 1 | Macro. |
Aggregation | 2 | Aggregate function. |
DatePart | 3 | Part of date value. |
Length | 4 | Length. |
Macro type. Specified with a value of the EntitySchemaQueryMacrosType enumeration, which is defined in the Terrasoft.Core.Entities namespace.
Function argument. Accepts a value if the function is defined with a parameter. The BaseExpression class is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace, is an ancestor for the ColumnExpresion class and has the same set of properties.
Part of date value Specified with a value from the DatePart enumeration, which is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
None | 0 | Not defined. |
Day | 1 | Day. |
Week | 2 | Week. |
Month | 3 | Month |
Year | 4 | Year. |
Weekday | 5 | Week day. |
Hour | 6 | Hour. |
HourMinute | 7 | Minute. |
Aggregate function type. Specified with a value from the AggregationType enumeration defined in the Terrasoft.Common namespace defined in the Terrasoft.Common class library.
Aggregate function scope. Specified with a value from the AggregationEvalType enumeration defined in the Terrasoft.Common namespace defined in the Terrasoft.Common class library.
Collection of subquery filters. The Filters type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
The Parameter class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The Parameter class is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. Its properties are available in table.
Properties
Type of data for the value that the added column will contain. Specified as a DataValueType enumeration value of the Terrasoft.Nui.ServiceModel.DataContract namespace.
Guid | 0 |
Text | 1 |
Integer | 4 |
Float | 5 |
Money | 6 |
DateTime | 7 |
Date | 8 |
Time | 9 |
Lookup | 10 |
Enum | 11 |
Boolean | 12 |
Blob | 13 |
Image | 14 |
ImageLookup | 16 |
Mapping | 18 |
The object that contains the value of the added column.
Array of the added column values. Used when serializing arrays and BLOBs.
Indicates the need to skip the process of providing the type for the Value property.
The ServerESQCacheParameters class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The ServerESQCacheParameters class is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. Its properties are available in table.
Properties
Data allocation level in the EntitySchemaQuery cache.
Caching group.
Repository record key.
The Filters class is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. For details on the properties of this class and its use, please see the Filters class article.
During the execution of DataService operations, it is often necessary to filter data. For example, when reading section records, you need to fetch only those records that meet certain criteria. Creatio provides the Filters class to form these criteria.
The Filters class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The Filters class is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace of the Terrasoft.Nui.ServiceModel.dll class library. For simplicity, the hierarchical structure of the Filters data filter is conveniently presented as a JSON format object:
Properties
A string containing the name of the root object schema of the added record.
Filter type. Set by the FilterType enumeration value of the Terrasoft.Nui.ServiceModel.DataContract namespace.
None | 0 | Filter type not defined. |
CompareFilter | 1 | Comparison filter. Used to compare expression results. |
IsNullFilter | 2 | The filter that defines whether an expression is empty. |
Between | 3 | The filter that defines whether an expression is one of the expressions. |
InFilter | 4 | The filter that defines whether an expression equals one of the expressions. |
Exists | 5 | Existence filter. |
FilterGroup | 6 | Filter group. Filter groups can be nested in one another, i.e., the collection itself can be an element of another collection. |
Comparison operation type. Set by the FilterComparisonType enumeration value of the Terrasoft.Core.Entities namespace.
Logical operation. This type does not allow the None value specified in the LogicalOperationStrict enumeration of the Terrasoft.Common namespace.
Expression completion checkbox.
Checkbox that defines whether the filter is active and will be taken into account when building a request.
Specifies whether to use the negation logical operator.
Subrequest filters. Cannot contain filters with other subrequests.
Collection containing a filter group.
The expression in the left part of the comparison, i.e. the expression to be tested. The BaseExpression class is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
The filter expression that will be compared to the expression contained in the LeftExpression property.
The expression array that will be compared to the expression contained in the LeftExpression property.
Initial filtration range expression.
Final filtration range expression.
Checkbox indicating whether to cut time from the date-time parameters.
Filter key in the collection of Items filters.
Aggregating filter checkbox.
Left comparison part title.
The object schema name referenced by the left part of the filter if the column type is lookup.
The BaseExpression class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The BaseExpression class is the base expression class. It is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace of the Terrasoft.Nui.ServiceModel library. The properties of this class instance are populated depending on the ExpressionType property that specifies the expression type. A complete list of the BaseExpression class properties is given in table.
Properties
The expression type that defines the value that will be contained in the added column. Set by the EntitySchemaQueryExpressionType enumeration of the Terrasoft.Core.Entities namespace defined in the Terrasoft.Core class library. For the InsertQuery the EntitySchemaQueryExpressionType.Parameter value is set.
SchemaColumn | 0 | Schema column. |
Function | 1 | Function. |
Parameter | 2 | Parameter. |
SubQuery | 3 | Subquery. |
ArithmeticOperation | 4 | Arithmetic operation. |
The path to a column relative to the root schema. The rules for building the paths can be found in the "The use of EntitySchemaQuery for creation of queries in database" article.
Defines the value that will be contained in the added column. Its Parameter type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
Function type. Set by the value from the FunctionType enumeration defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
None | 0 | Not defined. |
Macros | 1 | Macro. |
Aggregation | 2 | Aggregating function. |
DatePart | 3 | Date part. |
Length | 4 | Length. |
Macro type. Set by the value from the EntitySchemaQueryMacrosType enumeration defined in the Terrasoft.Core.Entities namespace.
Function argument. Takes the value if the function is defined with a parameter. The BaseExpression class is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace and is the ancestor of the ColumnExpresion class and has the same set of properties.
Date part. Set by the value from the DatePart enumeration defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
None | 0 | Not defined. |
Day | 1 | Day. |
Week | 2 | Week. |
Month | 3 | Month. |
Year | 4 | Year. |
Weekday | 5 | Day of the week. |
Hour | 6 | Hour. |
HourMinute | 7 | Minute. |
Aggregating function type. Sets the value of AggregationType enumeration defined in the namespace Terrasoft.Common defined in the class library Terrasoft.Common.
Aggregating function Set by the value from the AggregationEvalType enumeration defined in the Terrasoft.Core.DB namespace defined in the Terrasoft.Core class library.
Subquery filter collection. Its Filters type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
When creating queries to DataService, both parameterized (ie requiring an argument) and non-parameterized macros can be used. Macro types that must be used in the macro expressions are defined in the EntitySchemaQueryMacrosType enumeration in the Terrasoft.Core.Entities namespace. Enumeration values of macro types and their descriptions are available in table.
CurrentHalfYear | 16 | Current half-year (January-June or July-December). |
CurrentHour | 21 | Current hour. |
CurrentMonth | 10 | Current month. |
CurrentQuarter | 13 | Current quarter. |
CurrentUser | 1 | Current user. |
CurrentUserContact | 2 | Contact record of the current user. |
CurrentWeek | 7 | Current week. |
CurrentYear | 19 | Current year. |
DayOfMonth | 28 | Day of month. Requires parameterization. |
DayOfWeek | 29 | Week day. Requires parameterization. |
Hour | 30 | Hour. Requires parameterization. |
HourMinute | 31 | Time. Requires parameterization. |
Month | 32 | Month. Requires parameterization. |
NextHalfYear | 17 | Next half-year (January-June or July-December). |
NextHour | 22 | Next hour. |
NextMonth | 11 | Next month. |
NextNDays | 24 | Next N days. Requires parameterization. |
NextNHours | 26 | Next N hours. Requires parameterization. |
NextQuarter | 14 | Next quarter. |
NextWeek | 8 | Next week. |
NextYear | 23 | Next year. |
None | 0 | Type of macro not defined. |
PreviousHalfYear | 15 | Previous half-year (January-June or July-December). |
PreviousHour | 20 | Previous hour. |
PreviousMonth | 9 | Previous month. |
PreviousNDays | 25 | Previous N days. Requires parameterization. |
PreviousNHours | 27 | Previous N hours. Requires parameterization. |
PreviousQuarter | 12 | Previous quarter. |
PreviousWeek | 6 | Previous week. |
PreviousYear | 18 | Previous year. |
Today | 4 | Today. |
Tomorrow | 5 | Tomorrow. |
Year | 33 | Year. Requires parameterization. |
Yesterday | 3 | Yesterday. |
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The UpdateQuery data contract is used for updating section records. The query data is transferred to DataService via HTTP, with the help of POST by the URL.
The UpdateQuery data contract has a hierarchical structure with a number of nesting levels. In the Creatio server core, it is represented by a UpdateQuery class of the Terrasoft.Nui.ServiceModel.DataContract namespace of the Terrasoft.Nui.ServiceModel.dll library of classes. For the hierarchical data structure of the UpdateQuery data contract can be conveniently viewed in JSON format:
Properties
String that contains root schema name of added record object.
Type of write operation. Specified as a QueryOperationType enumeration value of the Terrasoft.Nui.ServiceModel.DataContract namespace. The QueryOperationType.Select value is set for SelectQuery.
Select | 0 |
Insert | 1 |
Update | 2 |
Delete | 3 |
Batch | 4 |
Indicates force update. If the value is true, the entity will be saved on the server even if column values have been modified. Default value: false.
Contains collection of column values for the added record. The ColumnValues type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
Collection of query filters. The <Filters type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
The ColumnValues class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The ColumnValues class has a single Items property, defined as a collection of keys and values Dictionary<string, ColumnExpression>. The key is the string with the name of the added column. The value is an object of the ColumnExpression type, defined in the Terrasoft.Nui.ServiceModel.DataContract namespace. General properties of the ColumnExpression class used when adding records are available in table.
Properties
Type of expression that determines the value that the added column will contain. Specified with a value from the EntitySchemaQueryExpressionType enumeration of the Terrasoft.Core.Entities namespace defined in the Terrasoft.Core class library. The EntitySchemaQueryExpressionType.Parameter value is set for InsertQuery.
SchemaColumn | 0 | Schema column. |
Function | 1 | Function. |
Parameter | 2 | Parameter. |
SubQuery | 3 | Subquery. |
ArithmeticOperation | 4 | Arithmetic operation. |
Determines the value that the added column will contain. The Parameter type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
The Parameter class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The Parameter class has a number of properties, only two of which are used for adding records.
Properties
Type of data for the value that the added column will contain. Specified as a DataValueType enumeration value of the Terrasoft.Nui.ServiceModel.DataContract namespace.
Guid | 0 |
Text | 1 |
Integer | 4 |
Float | 5 |
Money | 6 |
DateTime | 7 |
Date | 8 |
Time | 9 |
Lookup | 10 |
Enum | 11 |
Boolean | 12 |
Blob | 13 |
Image | 14 |
ImageLookup | 16 |
Mapping | 18 |
The object that contains the value of the added column. Has the Object type.
The Filters class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
An instance of the UpdateQuery class must contain a link to a correctly initialized instance of the Filters class in the Filters property. Otherwise, new column values from the ColumnValues property will be set for ALL section records.
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The DeleteQuery contract is used to delete sections. The data is transferred to the DataService via HTTP by using the POST request with the following URL:
The DeleteQuery data contract has a hierarchical structure with multiple nesting levels. In the Creatio application server part, the DeleteQuery data contract is represented by the DeleteQuery class of the Terrasoft.Nui.ServiceModel.DataContract namespace of the Terrasoft.Nui.ServiceModel.dll class library. However, for simplicity, the hierarchical structure of the DeleteQuery data contract is conveniently presented as a JSON format object:
Properties
A string containing the name of the root object schema of the added record.
Operation type is set by the QueryOperationType namespace Terrasoft.Nui.ServiceModel.DataContract namespace enumeration value. For the SelectQuery the QueryOperationType.Select value is set.
Select | 0 |
Insert | 1 |
Update | 2 |
Delete | 3 |
Batch | 4 |
Contains a collection of column values of the added record. Inherited from the BaseQuery parent class. Not used in this type of queries.
Query filter collection. Its Filters type is defined in the Terrasoft.Nui.ServiceModel.DataContract namespace.
The Filters class
The Namespace Terrasoft.Nui.ServiceModel.DataContract.
The DeleteQuery query class instance must contain a link to the correctly initialized Filters class instance in the Filters property. Otherwise ALL section records will be deleted.
Batch queries are used to minimize requests to DataServise, which improves application performance. Packet query is a collection that contains a custom set of DataService requests. The query data is transferred to DataService via HTTP, with the help of POST by the URL.
The data that comprises a batch query can be passed in different formats. One of the more convenient formats is JSON.
To generate the contents of one-time queries that comprise a batch query, use the following data constants: InsertQuery, SelectQuery, UpdateQuery and DeleteQuery.