
In a previous article I showed how to open a page from code on a Freedom UI page using the HandlerChainService. This article will expand on that topic and show how to open a page in add or edit mode. In order to do this, you’ll use the HandlerChainService which is in the DevKit SDK.
To use this devkit, you’ll need to add “@creatio-devkit/common” to the modules list of your page. This will look like this (note the “@creatio-devkit/common” in the square brackets and the sdk without quotes in the parenthesis):
define("UsrMyCustomEntity_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ { return { // ... the rest of the page here }; });
Now, with that module available, you can access things in the SDK such as the HandlerChainService module.
Open an Edit Page in ADD Mode
To open a page in Add mode, to add a new record, we’ll use a crt.CreateRecordRequest and provide the Entity name for the object we’re adding the record for, such as “Contact”. Optionally, we can also provide default values to set on the page for the new record, which is useful to relating the new record to the one we are currently on (for example, to associate a new Contact with the Account we’re currently viewing).
const handlerChain = sdk.HandlerChainService.instance; // open the add contact page, default the Name await handlerChain.process({ type: "crt.CreateRecordRequest", entityName: "Contact", $context: request.$context, defaultValues: [{ attributeName: "Name", value: "New contact" }] });
Open an Edit Page in EDIT Mode
To open a specific record in Edit mode, we’ll use a crt.UpdateRecordRequest and provide the entity name and an Id value.
const handlerChain = sdk.HandlerChainService.instance; // open a Contact page for the contact with Id in someContactId await handlerChain.process({ type: "crt.UpdateRecordRequest", entityName: "Contact", $context: request.$context, recordId: someContactId });
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!