back to top

Creating or Updating Records Using the Entity Class in Creatio

If you need to create a record in C# code in Creatio, the best option to take is using the Entity class. You’re likely already using the Entity class, when you perform a query using EntitySchemaQuery in server-side code, you’re getting back either an Entity object, or an EntityCollection (a collection of Entity objects). The Entity class represents *any* Entity in the system, which this is something I really like about it, rather than using a strongly typed object specific to one Entity. In my opinion this makes it extremely flexible and very easy to use. Let’s take a look at how to use it to create a record.

Creating a Record

In the sample below we will be creating a Contact record.

// using Terrasoft.Core.Entities;

var schema = UserConnection.EntitySchemaManager.GetInstanceByName("Contact");
// Create an instance of a new object
var entity = schema.CreateEntity(UserConnection);
// Set any default values for the object columns
entity.SetDefColumnValues();
entity.SetColumnValue("Name", "Ryan Farley");
entity.SetColumnValue("Phone", "800-555-1212");
entity.Save();

That is it, very easy. The Save method also has some options we can use. It takes an optional boolean parameter for validateRequired – (Default: true) This indicates whether to validate that required fields for the entity are being set. If you change this to false it will allow you to add the record without required values.

Updating a Record

Let’s say you have a record Id and you want to (1) get this record from the database and (2) update a value of column(s) for the record. In this sample, we will be updating a Contact record, given the record Id value.

//using Terrasoft.Core.Entities;

var schema = UserConnection.EntitySchemaManager.GetInstanceByName("Contact");
// Create an instance of a new object
var entity = schema.CreateEntity(UserConnection);
// Now load the contact record using it's Id value
if (entity.FetchFromDB(Id))
{
    entity.SetColumnValue("Phone", "800-728-5783");
    entity.Save();
}

The code above will load the record into the Entity object, if the load is successful, meaning the record exists, it will update it’s Phone value.

The Entity class includes a lot of useful methods to do things like validate if required fields are populated, serializing it to JSON, reverting the set columns back to a previous state and even setting byte array for object columns.

Note, the Entity class isn’t the only way to create or update records, there are other options like the Insert and Update classes, however, using the Entity class will ensure that added/modified signals are still triggered for processes and access permissions are still applied.

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