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

Embedding a Creatio Chat Widget on your Website in Less than 5 Minutes

Creatio version 10X has an out of the box...

Query the Creatio Database to Locate Source Code or Client Schemas Containing a Value

Often when working with Creatio, I need to locate...

Building AI-Powered Workflows in Creatio Without Writing Code

See how Creatio can combine AI with no-code business processes to qualify, summarize, and route incoming leads while keeping your existing business rules and human oversight in place.

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.

Related Articles

Embedding a Creatio Chat Widget on your Website in Less than 5 Minutes

Creatio version 10X has an out of the box feature that allows you to easily embed a Chat...

Query the Creatio Database to Locate Source Code or Client Schemas Containing a Value

Often when working with Creatio, I need to locate code or client schemas based on their content, not...

Building AI-Powered Workflows in Creatio Without Writing Code

See how Creatio can combine AI with no-code business processes to qualify, summarize, and route incoming leads while keeping your existing business rules and human oversight in place.

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.

Related Videos