Creating an Edit Page for a Lookup in Creatio

You’ve likely noticed that some lookups in Creatio have an edit page where there are additional details for a lookup item. Other lookups, like the lookups you create, do not have an edit page. Additionally, the lookups with an edit page allow for items to be added to the lookup on the fly, by users. Lookups with an edit page will have the “New” option in the lookup dialog:

For lookups with an edit page, users will also see a “New” option if they type a value in to the lookup that doesn’t exist, allowing the value to be quickly added:

Obviously, for lookups with an edit page, you’ll also see the icon to open the edit page for a lookup item when you are in the lookup section and select an item in the lookup:

To add an edit page to a lookup, you must complete the following steps:

  1. Create a section schema for your lookup – with “Base lookup configuration section” as parent
  2. Create a page schema for your lookup – with “Base lookup page” as parent
  3. Register the schema and edit page schemas for your lookup. This is done via SQL directly in the database
  4. Select the section schema for your lookup in the lookup properties

This article will outline all the details to perform these steps. It will look like a lot of work, however, keep in mind, for some of the steps I will outline some different options for the step, including both an MSSQL and Postgresql version of the last step.

STEP 1: Create a Section For Your Lookup

The first step is to create a new “Section view model”

You’ll need to select “Base lookup configuration section” (BaseLookupConfigurationSection) as the parent for your new section schema. Then paste in the following code:

define("UsrMyLookupSection", ["ConfigurationEnums", "ConfigurationGrid", "ConfigurationGridGenerator",
    "ConfigurationGridUtilities"],
function(ConfigurationEnums) {
    return {
        entitySchemaName: "UsrMyLookup",
        attributes: {},
        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,
        messages: {},
        methods: {}
    };
});

Note, you’ll need to change the “entitySchemaName” value to be the name of your lookup object. You’ll also want to change the name from UsrMyLookupSection to something for your lookup object.

OPTIONAL

If you’d like to make your edit page appear when a new lookup item is added, instead of just adding an editable row to the lookup, you can add the section code like below, instead of the one above:

define("UsrMyLookupSection", ["ConfigurationEnums", "ConfigurationGrid", "ConfigurationGridGenerator",
    "ConfigurationGridUtilities"],
function(ConfigurationEnums) {
    return {
        entitySchemaName: "UsrMyLookup",
        attributes: {},
        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,
        messages: {},
        methods: {
            addRecord: function(typeColumnValue) {
                if (!typeColumnValue) {
                    if (this.get("EditPages").getCount() > 1) {
                        return false;
                    }
                    var tag = this.get("AddRecordButtonTag");
                    typeColumnValue = tag || this.Terrasoft.GUID_EMPTY;
                }
                var schemaName = this.getEditPageSchemaName(typeColumnValue);
                if (!schemaName) {
                    return;
                }
                this.openCardInChain({
                    schemaName: schemaName,
                    operation: ConfigurationEnums.CardStateV2.ADD,
                    moduleId: this.getChainCardModuleSandboxId(typeColumnValue)
                });
            }
        }
    };
});

STEP 2: Create an Edit Page For Your Lookup

The next step is to create an edit page for your lookup. To do this, add a “Base lookup page”:

You’ll need to select “Base lookup page” (BaseLookupPage) as the parent. Then paste in the following code:

define("UsrMyLookupEditPage", [],
function() {
    return {
        entitySchemaName: "UsrMyLookup",
        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
        attributes: {},
        methods: {},
        rules: {},
        diff: /**SCHEMA_DIFF*/[
            {
                "operation": "merge",
                "name": "Name",
                "parentName": "GeneralInfoControlGroup",
                "propertyName": "items",
                "values": {
                    "layout": {
                        "colSpan": 12,
                        "column": 0,
                        "row": 0
                    }
                }
            }
        ]/**SCHEMA_DIFF*/
    };
});

Note, be sure to change the entitySchemaName for your lookup object. Also change the UsrMyLookupEditPage value to something more meaningful for your lookup object. Also, you can easily add more fields to the diff for your lookup object – if you have additional fields in your lookup object.

STEP 3: Register Your Schema and Edit Page in the Database

Now you need to register your section and edit page schemas in the database. For this step, you’ll need to select either the MSSQL or Postgresql version for your database. If you’re not sure which database type you have, simply execute the following SQL (using the SQL Executor marketplace add-on):

select @@version

If you’re on MSSQL, you’ll get back the version of SQL your system is on. If you’re on Postgresql, you’ll get back an error saying “Npgsql.PostgresException (0x80004005): 42703: column “version” does not exist”.

POSTGRESQL VERSION

Note, change the values for the three variables at the top to (1) the name of your edit page schema (2) the name of your lookup object (3) what you want the title of your edit page schema to be. Execute the following with the SQL Executor:

do $$
declare
    -- Name of edit page schema
    CardSchemaName char(100) := 'UsrMyLookupEditPage';
    -- Name of object schema
    EntitySchemaName char(100) := 'UsrMyLookup';
    -- Caption of your page
    PageCaption char(100) := 'My lookup edit page';
begin
    insert into "SysModuleEntity" (
        "ProcessListeners",
        "SysEntitySchemaUId"
    )
    values (
        0,
        (select "UId"
        from "SysSchema"
        where "Name" = EntitySchemaName
        limit 1
        )
    );
    
    insert into "SysModuleEdit" (
        "SysModuleEntityId",
        "UseModuleDetails",
        "Position",
        "HelpContextId",
        "ProcessListeners",
        "CardSchemaUId",
        "ActionKindCaption",
        "ActionKindName",
        "PageCaption"
    )
    values (
        (select "Id"
        from "SysModuleEntity"
        where "SysEntitySchemaUId" = 
            (select "UId"
            from "SysSchema"
            where "Name" = EntitySchemaName
            limit 1
            )
        limit 1
        ),
        true,
        0,
        '',
        0,
        (select "UId"
         from "SysSchema"
         where "Name" = CardSchemaName
         limit 1
        ),
        '',
        '',
        PageCaption
    );
    
    insert into "SysModuleEditLcz" ("RecordId", "SysCultureId", "ActionKindCaption", "PageCaption")
    values (
    	(select sme."Id"
		from "SysModuleEdit" as sme
			left join "SysModuleEntity" as sment on sment."Id" = sme."SysModuleEntityId"
			left join "SysSchema" as sse on sse."UId" = sment."SysEntitySchemaUId"
			left join "SysSchema" as ss on ss."UId" = sme."CardSchemaUId"
		where sse."Name" = EntitySchemaName
    		and ss."Name" = CardSchemaName
		order by sme."CreatedOn" desc
		limit 1
    	), 
    	'A5420246-0A8E-E111-84A3-00155D054C03', 
    	'Add', 
    	PageCaption);
end $$;

MSSQL VERSION

Note, change the values for the three variables at the top to (1) the name of your edit page schema (2) the name of your lookup object (3) what you want the title of your edit page schema to be. Execute the following with the SQL Executor:

DECLARE
-- Name of edit page schema
@CardSchemaName NCHAR(100) = 'UsrMyLookupEditPage',
-- Name of object schema
@EntitySchemaName NCHAR(100) = 'UsrMyLookup',
-- Caption of your page
@PageCaption NCHAR(100) = 'My lookup page'

insert into SysModuleEntity(
    ProcessListeners,
    SysEntitySchemaUId
)
values(
    0,
    (select TOP 1 UId
    from SysSchema
    where Name = @EntitySchemaName
    )
)

insert into SysModuleEdit(
    SysModuleEntityId,
    UseModuleDetails,
    Position,
    HelpContextId,
    ProcessListeners,
    CardSchemaUId,
    ActionKindCaption,
    ActionKindName,
    PageCaption
)
values (
    (select top 1 Id
    from SysModuleEntity
    where SysEntitySchemaUId = (
        select TOP 1 UId
        from SysSchema
        where Name = @EntitySchemaName
        )
    ),
    1,
    0,
    '',
    0,
    (select top 1 UId
     from SysSchema
     where Name = @CardSchemaName
    ),
    '',
    '',
    @PageCaption
)

insert into SysModuleEditLcz (RecordId, SysCultureId, ActionKindCaption, PageCaption)
values (
  (select top 1 sme.Id
		from SysModuleEdit as sme
			left join SysModuleEntity as sment on sment.Id = sme.SysModuleEntityId
			left join SysSchema as sse on sse.UId = sment.SysEntitySchemaUId
			left join SysSchema as ss on ss.UId = sme.CardSchemaUId
		where sse.Name = @EntitySchemaName
    		and ss.Name = @CardSchemaName
		order by sme.CreatedOn desc
  ), 
  'A5420246-0A8E-E111-84A3-00155D054C03', 
  'Add', 
  @PageCaption
)

STEP 4: The Final Step is to Select Your Section in Lookup Properties

Once you’ve executed the SQL statement to register your page, the final step is to go to the properties of your lookup in the lookup section to select your section schema. Select your lookup and click Lookup Properties

In the page that opens select your section schema you created in step 1 (note, select the section schema, NOT the edit page schema):

Once you’ve done this, you need to log out and then back in again and you’re done.

ABOUT THE AUTHOR

Ryan Farley

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.

Submit a Comment

Your email address will not be published. Required fields are marked *

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!