back to top

Performing a Model Load Query on a Creatio Freedom UI Page to Check if a Contact is a User

For Freedom UI pages, I’ve mentioned in previous articles that the new Freedom UI equivalent to performing EntitySchemaQuery is now using the Model class. The model class allows you to load, or query, data using conditions. In this article I will show an example for the Contacts_FormPage to check if the current contact record is also a Creatio user.

To perform this query, we’ll query Contact where the Id is the current record Id, but also include that the contact exists in a subquery of System Administration Unit (SysAdminUnit) where SysAdminUnitTypeValue = 4 and ConnectionType = 0

  • SysAdminUnitTypeValue of 4 indicates that the SysAdminUnit record is a user (the table also stores roles, etc)
  • ConnectionType of 0 indicates that the user is a company employee (full Creatio user). If you wanted to check if the user is a external (portal) user, you’d use a value of 1 instead.

The Model class is available via the new 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("Contacts_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. For this example, I’ve also added an attribute to the page, called ContactIsUser. I can later use that attribute to show/hide things as needed for contacts that are also users.

const id = await request.$context.Id;
const model = await sdk.Model.create("Contact");

const filters = new sdk.FilterGroup(sdk.LogicalOperatorType.And);
await filters.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Id", id);

const subFilters = new sdk.FilterGroup();
await subFilters.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "ConnectionType", 0);
await subFilters.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SysAdminUnitTypeValue", 4);

await filters.addExistsFilter("[SysAdminUnit:Contact].Id", subFilters);

const data = await model.load({
    attributes: ["Id"],
    parameters: [{
        type: sdk.ModelParameterType.Filter,
        value: filters
    }]
});

request.$context.ContactIsUser = (data.length > 0);

In the code above, I create a model for Contact (the table I am querying). I add a filter condition for the contact Id. I then create filters for the subquery and last add an exists filter for the subquery. The end result is that the query will return 1 record if the contact is a user or will return 0 records if the contact is NOT a user. I have added this code to the model init request of the page.

Now, to use my attribute, I can bind it to the visible property of anything I want to show for contacts that are also users:

"visible": "$ContactIsUser"

Or anything I only want to show for contacts that are NOT users:

"visible": "$ContactIsUser | crt.InvertBooleanValue"

Just to point out, the query above is equivalent to this contact filter:

Also, you could definitely also query SysAdminUnit directly, without the subquery, using the conditions below to get the same result:

  • Contact = the Id of the contact
  • ConnectionType = 0
  • SysAdminUnitTypeValue = 4

However, for this article, I thought it would be useful to show an example with a subquery and exists filter.

Note, you can use the same filter outlined in this article (minus the Id equals the current contact Id) to load a list of all contacts that are users.

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