
In this first article on using the Model class I’ll be showing how to get the schema of an object. The model class in the DevKit SDK is the new API for working with entity data in Freedom UI pages. Previously in classic Creatio pages, you’d create EntitySchemaQuery objects to query data, InsertQuery to create new records, UpdateQuery to update records, or DeleteQuery to delete data. All of this is now replaced with the Model class in Freedom UI pages. 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("UsrMyCustomEntity_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. In this article our focus will be to retrieve an entity/object schema, including the title, primary display property and the list of all columns/properties for the object.
As an example, we’ll be retrieving the schema for the Account object. The code is simple and will look as follows:
const account = await sdk.Model.create("Account"); const accountSchema = await account.getSchema();
So what does that look like? For the Account object, if I dumped that out to the console it would look as follows:
I’ve not expanded all the properties in that screenshot because there is really a lot of info provided. Not only do you get the column names and captions, you also get default values, if it’s required, it it copies with new records, and even validators.
Here’s what the Owner column looks like, notice the default values:
Here’s the GPS E field, that has a max length validator:
It certainly is more simple that the previous methods for retrieving the schema info for objects.
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!