back to top

Inserting a Record from Client-Side Code using InsertQuery in Creatio (formerly bpm’online)

There might be times when you need to insert a record from client-side code on a page in Creatio. While it is easy to add records in a process, you can also do the same from the form code itself using an InsertQuery object. Let’s take a look.

For this scenario, we’ll say we have an object named UsrWidget that’s related to Account. From the account page, we’ll programmatically create a new widget record and relate it to the account. The code for using InsertQuery will look a lot like an EntitySchemaQuery. We’ll create the object and specify the rootSchemaName we’re inserting into and then set the column values to include. Finally, we’ll execute the insert, which also allows for us to specify a callback to happen after the insert is complete (so we could do something like refresh a detail we’ve inserted into, for example). The code would look something like this:

var insert = Ext.create("Terrasoft.InsertQuery", { rootSchemaName: "UsrWidget" });
insert.setParameterValue("UsrAccount", this.get("Id"), Terrasoft.DataValueType.GUID);
insert.setParameterValue("UsrQuantity", 1, Terrasoft.DataValueType.INTEGER);
insert.setParameterValue("UsrPrice", 200.00, Terrasoft.DataValueType.FLOAT);
insert.setParameterValue("UsrInclude", true, Terrasoft.DataValueType.BOOLEAN);
insert.setParameterValue("UsrSerialNumber", "123456", Terrasoft.DataValueType.TEXT);
insert.execute();

The first line simply creates the InsertQuery object and specifies the type of entity object we’re inserting. Then we set each column value, which we also have to specify what the type is for that column value using Terrasoft.DataValueType. How do we know the available types for Terrasoft.DataValueType? You can see all of the possible values in the documentation, or you can open up your browser’s DevTools on a Creatio page (any page) and type “Terrasoft.DataValueType” in the console and hit enter and you’ll see the list of available types.

Lastly, we execute the insert. In the code above, we’re just executing it, however we can also provide a callback function to execute after the insert is complete. Like this:

insert.execute(function() {
    // do something here
}, this);

or this:

insert.execute(this.myCallbackFunction, this);

In the following two articles, I will cover doing the same with updates and deletes.

As always, you should always consider where the best place is to perform an operation like this. Keep in mind, doing this from the page code means that the logic won’t happen for imports or things that might trigger from other server events since it only exists on the page.

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