Auto-apply business rules to records that are added by a custom request handler
This functionality is available for Creatio 8.1.4 and later.
Since version 8.1.4, Creatio lets you execute business rules whenever custom request handler adds a record to a collection. For example, use the functionality if you need to populate a collection of records, apply business rules for each record and output the result in a section list.
To auto-apply business rules to collection records that a custom request handler adds:
- Go to the
handlers
schema section. - Implement a custom request handler if needed.
- Add a
createItem()
method that creates a new record, for example, when you click the Add button. - Set the
businessRulesActive
property totrue
. The property auto-applies business rules to a new collection record.
View the example that implements a custom usr.AddRecordRequest
request handler of the Freedom UI page schema below. The handler is bound to the clicked
button event and adds the "John Smith" record to the section list. If the businessRulesActive
property is set to true
, Creatio automatically applies business rules to a new collection record. Otherwise, Creatio does not apply business rules to a new collection record until the record is selected in the section list.
- Auto-applying of business rules is disabled out of the box
- Auto-applying of business rules is enabled
handlers: /**SCHEMA_HANDLERS*/[{
/* The custom implementation of the custom request handler. */
request: "usr.AddRecordRequest",
handler: async (request, next) => {
/* The section list collection that the Freedom UI section page displays. */
const collection = await request.$context.Items;
/* Add a new record of the section list collection. */
await collection.createItem({
/* Set the "Name" field to "John Smith." */
initialModelValues: { Name: 'John Smith'}
});
return next?.handle(request);
}
}]/**SCHEMA_HANDLERS*/,
handlers: /**SCHEMA_HANDLERS*/[{
/* The custom implementation of the custom request handler. */
request: "usr.AddRecordRequest",
handler: async (request, next) => {
/* The section list collection that the Freedom UI section page displays. */
const collection = await request.$context.Items;
/* Add a new record of the section list collection. */
await collection.createItem({
/* Set the "Name" field to "John Smith." */
initialModelValues: { Name: 'John Smith'},
/* Auto-apply business rules to collection records that a custom request handler adds. */
businessRulesActive: true
});
return next?.handle(request);
}
}]/**SCHEMA_HANDLERS*/,
See also
Set up List components (user documentation)