Updating a Record from Client-Side Code Using the Model Class in a Creatio Freedom UI Page

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:

  1. success: true/false
  2. rowsAffected: Number of rows affected by the operation, in the case for the example above, 1
Want content like this delivered to your inbox? Sign up for our newsletter!

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *