How to Find the Page ObjectName and RecordId of an Open Form Page in Creatio?

Hi Community,

I'm trying to identify the ObjectName (schema name) and the RecordId of a form page that is currently open in Creatio (Freedom UI), using the context data available (as shown in the attachment). Is there a recommended way to retrieve this information through code or the browser console?

What’s the best way to access this data from within the button click handler?

Reference Screenshot

Thanks in advance!

Ajay K

Like 1

Like

1 comments

This is possible, but only from the context of the page itself. I am not sure if it's possible from a sidebar to know anything about the current page loaded elsewhere, maybe with a request handler in a remote module where you can specify the scopes?

As for getting this info within the context of the page, to get the primary data source, you can use: 

const pds = await request.$context.getPrimaryModelName();

With the data source name, you can get the schema for the datasource which will give you the entity/object name, the Id column attribute, and also the primary display value attribute using the following (note, this gets the attribute names, not the values): 

const pds = await request.$context.getPrimaryModelName();
const schema = await request.$context.dataSchemas[pds];
 
const entityName = await schema.name;
const idColumn = await schema.primaryAttributeName;
const nameColumn = await schema.primaryDisplayAttributeName;

Now that you have the attribute names, you can get the values: 

const idValue = await request.$context[idColumn];
const nameValue = await request.$context[nameColumn];
// etc

This sort of thing works great if you have a custom base page type that could be used for many different pages/objects. 

Also, as a FYI, not sure how this is going to change after 8.2.3 since 8.2.3 has a beta feature (not enabled out of the box) that allows a page to have multiple connected data sources. That might break some of this.

Ryan

Show all comments