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.



