back to top

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

Creatio includes the ability to copy records. When copying, only the properties that are marked as “clonable” are copied to the new record and the properties that are not marked for copy are not included. Creaio’s new Model class includes this same capability to copy records. To copy a record we’ll use 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 the Id of the record we want to copy and we’ll be provided with a payload.  The payload it gives back to us will be the original record in copy mode. This means that only the clonable properties will be loaded. We can modify that payload further if we want, and then use the Model class insert function to save the new copied record. The overall flow will be as follows:

  1. Create the model
  2. Call the copy function and pass the Id of the record to copy which returns a payload for a copied record of the original
  3. Modify the payload, if necessary
  4. Call the insert function and provide the payload we got back from the copy

Let’s take a look at the code:

const accountModel = await sdk.Model.create("Account");

// get a copied payload of the record we're copying
const copiedAccount = await accountModel.copy(someAccountIdToCopy);

// modify payload if necessary
copiedAccount.Name = "New name of account";

// insert the copied record
accountModel.insert(copiedAccount);

One thing to make clear here. If you don’t insert the copied record, there’s nothing saved to the database at all. Calling copy simply provides you with a payload. It’s like you just loaded the record, but only loaded the clonable properties. Additionally, the Id of the record, in the payload, will have a new Guid value for the new record. However, nothing is saved in the database until you’ve passed this payload to insert.

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Ryan Farley
Ryan Farleyhttps://customerfx.com/article/author/ryanfarley/
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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

AI Readiness Checklist for CRM Teams: Is Your CRM System Ready for AI?

Before using AI in Creatio, make sure your CRM data, users, processes, and automation foundation are ready. Use this practical AI readiness checklist for CRM teams.

Build Your Creatio AI Skills with the 2026 AI Summer Program

Join Creatio’s free 2026 AI Summer Program to learn how to identify, build, deploy, and manage AI agents.

Creatio 10x Is Coming: Join the Webinar to Explore the Future of AI-Native CRM

Learn what's new in Creatio 10x and how AI-native CRM, agentic AI, and no-code automation are shaping the future of customer relationship management. Join the upcoming webinar and discover what's next.

Creatio Unlimited Pricing Explained: AI Packages, Costs, Pros & Cons

Learn what Creatio’s new Unlimited pricing model includes, what it doesn’t include, how AI Action packages work, and the pros and cons for businesses evaluating Creatio.

Using the AI Prompt to Create Dynamic Folders in Creatio

Using Creatio's AI prompt to create the filter for a dynamic folder works best if you specifically ask for that, and if you are as clear and direct as possible about the filtering, conditions.

Related Articles

AI Readiness Checklist for CRM Teams: Is Your CRM System Ready for AI?

Before using AI in Creatio, make sure your CRM data, users, processes, and automation foundation are ready. Use this practical AI readiness checklist for CRM teams.

Build Your Creatio AI Skills with the 2026 AI Summer Program

Join Creatio’s free 2026 AI Summer Program to learn how to identify, build, deploy, and manage AI agents.

Creatio 10x Is Coming: Join the Webinar to Explore the Future of AI-Native CRM

Learn what's new in Creatio 10x and how AI-native CRM, agentic AI, and no-code automation are shaping the future of customer relationship management. Join the upcoming webinar and discover what's next.

Creatio Unlimited Pricing Explained: AI Packages, Costs, Pros & Cons

Learn what Creatio’s new Unlimited pricing model includes, what it doesn’t include, how AI Action packages work, and the pros and cons for businesses evaluating Creatio.

Related Videos