
In classic Creatio pages, to update a record you would use an UpdateQuery. Now, in Freedom UI pages you can update records using the Model class that is a part of the Creatio DevKit SDK.
To use the 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 Model class. We’ll use this model class to create a model for a specific entity. Then, we’ll pass two things to the Model’s update function, (1) the payload of what we want to update on the record, and (2) the parameters for which records to update (which will include the filters for the records you want to update).
The payload we’ll pass includes only those fields we want to change. It is an object with name/value pairs of the Column names and values to set for each. In the example below, we’ll be updating the name of a single account. We will first create a model for the Account, then provide the object with the Name column and new name value, and lastly include an object with the filters for the record we want to update. Let’s look at the code below:
const accountModel = await sdk.Model.create("Account"); const result = await accountModel.update( { Name: "New account name" // include any other fields to update... }, [{ type: sdk.ModelParameterType.PrimaryColumnValue, value: someAccountId }] );
The result returned by the update provides an object with the following properties:
- success: true/false
- rowsAffected: Number of rows affected by the operation, in the case for the example above, 1
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!