Article

Register custom section for existing object

Prerequisites

The object must have displayed value.

1. Run script in dev environment to create [glb_RegisterSection] stored procedure

glb_RegisterSection stored procedure

CREATE OR ALTER PROC [glb_RegisterSection] (
  @EntityName       NVARCHAR(100),
  @SectionCaption   NVARCHAR(100),
  @SectionPageName  NVARCHAR(100),
  @EditPageName     NVARCHAR(100)
)
AS BEGIN TRANSACTION;
   SET NOCOUNT ON;
   SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
   SET XACT_ABORT ON;
BEGIN TRY
IF @EntityName = ''
    THROW 50001, 'Parameter @EntityName is empty', 1;
IF @SectionCaption = ''
    THROW 50001, 'Parameter @SectionCaption is empty', 1;
DECLARE @SysModuleId        UNIQUEIDENTIFIER = NEWID();
DECLARE @SysModuleEditId    UNIQUEIDENTIFIER = NEWID();
DECLARE @SysModuleEntityId  UNIQUEIDENTIFIER = NEWID();
DECLARE @SysEntitySchemaUId UNIQUEIDENTIFIER;
DECLARE @SectionSchemaUId   UNIQUEIDENTIFIER;
DECLARE @CardSchemaUId      UNIQUEIDENTIFIER;
DECLARE @ActionKindName     NVARCHAR(250);
DECLARE @PageCaption        NVARCHAR(250);
SELECT TOP 1
    @SysEntitySchemaUId = UId,
    @ActionKindName = Caption
FROM SysSchema
WHERE Name = @EntityName
    AND ExtendParent = 0;
SELECT TOP 1
    @SectionSchemaUId = UId
FROM SysSchema
WHERE Name = @SectionPageName
    AND ExtendParent = 0;
SELECT TOP 1
    @CardSchemaUId = UId,
    @PageCaption = Caption
FROM SysSchema
WHERE Name = @EditPageName
    AND ExtendParent = 0;
IF @SysEntitySchemaUId IS NULL
    THROW 50002, 'Entity not found. Check @EntityName input parameter.', 1;
IF @SectionSchemaUId IS NULL
    THROW 50002, 'Section page not found. Check @SectionPageName input parameter.', 1;
IF @CardSchemaUId IS NULL
    THROW 50002, 'Edit page not found. Check @EditPageName input parameter.', 1;
INSERT INTO SysModuleEntity (
    Id,
    SysEntitySchemaUId)
VALUES (
    @SysModuleEntityId,
    @SysEntitySchemaUId
);
INSERT INTO SysModuleEdit (
    Id,
    SysModuleEntityId,
    CardSchemaUId,
    UseModuleDetails,
    ActionKindCaption,
    ActionKindName,
    PageCaption)
VALUES (
    @SysModuleEditId,
    @SysModuleEntityId,
    @CardSchemaUId,
    1,
    'New',
    @ActionKindName,
    @PageCaption
);
INSERT INTO SysModule (
    Id,
    Caption,
    Code,
    SectionSchemaUId,
    SysModuleEntityId,
    CardSchemaUId,
    FolderModeId,
    SectionModuleSchemaUId,
    CardModuleUId,
    Image32Id)
VALUES (
    @SysModuleId,
    @SectionCaption,
    @EntityName,
    @SectionSchemaUId,
    @SysModuleEntityId,
    @CardSchemaUId,
    'B659D704-3955-E011-981F-00155D043204',
    'DF58589E-26A6-44D1-B8D4-EDF1734D02B4',
    '4E1670DC-10DB-4217-929A-669F906E5D75',
    '026742D9-390C-4778-BC46-9FA85C42677A'
);
SELECT
    @SysModuleId AS SysModule,
    @SysModuleEntityId AS SysModuleEntity,
    @SysModuleEditId AS SysModuleEdit;
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber,
       ERROR_MESSAGE() AS ErrorMessage;
IF @@TRANCOUNT > 0
    ROLLBACK TRANSACTION;
END CATCH;
IF @@TRANCOUNT > 0
    ROLLBACK TRANSACTION;

2. Create section and edit pages (if not exist)

 

Create Section page (parent BaseSectionV2)

define("UsrEntitySectionV2", [], function() {
    return {
        entitySchemaName: "UsrEntity",
        messages: {},
        mixins: {},
        attributes: {},
        methods: {},
        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
    };
});

Create Edit page (parent BaseModulePageV2)

define("UsrEntityPageV2", [], function() {
    return {
        entitySchemaName: "UsrEntity",
        messages: {},
        mixins: {},
        attributes: {},
        methods: {},
        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
    };
});

 

3. Execute a stored procedure in dev environment to register section.

Stored procedure [glb_RegisterSection] takes such arguments: EntityName, SectionCaption, SectionPageName, EditPageName.

Example

exec dbo.[glb_RegisterSection] 'UsrEntity', 'My entities', 'UsrEntitySectionV2', 'UsrEntityPageV2'



4. Bind new data to a package with a filter by IDs from output for the following system tables:

  • SysModuleEntity
  • SysModule
  • SysModuleEdit

Standard list of objects

EntityName, EntityName + "Folder", EntityName + "File", EntityName + "InFolder", EntityName + "Tag", EntityName + "InTag"

Like 0

Like

Share

9 comments

Can I use this approach to create new section for the "Relationship" object or "ContactCareer" object of BPM that came out of the box? If so, are there any extra steps I need to take?

 

kumar,

You can use this instruction to create a new section for the object.

Some details: 

When you create edit page and section page you should choose that options instead of module http://prntscr.com/mb5d9o



Also, it`s necessary to create a backup of the database before adding the section because it`s pretty difficult operation that can cause issues.



Please note, that created section and edit page should not contain the prefix because objects that you specified are system ones. You can simply temporarily remove it from the system setting "Prefix for object name".



And also it necessary to clear redis, relogin and compile the system after section was added.



Best regards,

Alex

Alex_Tim,

Do you know if it is possible to also add section folders when using this method? I've used the above to cover an object created as a detail to a full section, but not sure how to add & relate the EntityFolder and EntityInFolder objects so I can create folders in the section. Is this possible?

Thanks,

Ryan

For anyone else that comes across this, to add folders, all you need to do is add a new object named EntityName + "Folder" that inherits from BaseFolder as well as Entity + "InFolder" that inherits from BaseItemInFolder (and also add a lookup property to your custom entity as well as change the lookup for the virtual Folder property of the inherited properties). The code above already specifies the correct FolderModeId so once you add the object, log out and back in again, then you'll have folders for the entity.

Hello,

There is a failed case in this script. When an object has already been added in a Detail, it will duplicate SysModuleEntity, and the new edit page won't be used. System always uses the first page created. Therefore the detail edit page and the section edit page will always be the same. I updated the script a little bit to check if the SysModuleEntity and SysModuleEdit are created. 

 

CREATE OR ALTER PROC [glb_RegisterSection] (
	@EntityName       NVARCHAR(100),
	@SectionCaption   NVARCHAR(100),
	@SectionPageName  NVARCHAR(100),
	@EditPageName     NVARCHAR(100)
)
AS BEGIN TRANSACTION;
	SET NOCOUNT ON;
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
	SET XACT_ABORT ON;
BEGIN TRY
IF @EntityName = ''
	THROW 50001, 'Parameter @EntityName is empty', 1;
IF @SectionCaption = ''
	THROW 50001, 'Parameter @SectionCaption is empty', 1;
DECLARE @SysModuleId        UNIQUEIDENTIFIER = NEWID();
DECLARE @SysModuleEditId    UNIQUEIDENTIFIER;
DECLARE @SysModuleEntityId  UNIQUEIDENTIFIER;
DECLARE @SysEntitySchemaUId UNIQUEIDENTIFIER;
DECLARE @SectionSchemaUId   UNIQUEIDENTIFIER;
DECLARE @CardSchemaUId      UNIQUEIDENTIFIER;
DECLARE @ActionKindName     NVARCHAR(250);
DECLARE @PageCaption        NVARCHAR(250);
SELECT TOP 1
	@SysEntitySchemaUId = UId,
	@ActionKindName = Caption
FROM SysSchema
WHERE Name = @EntityName
	AND ExtendParent = 0;
SELECT TOP 1
	@SectionSchemaUId = UId
FROM SysSchema
WHERE Name = @SectionPageName
	AND ExtendParent = 0;
SELECT TOP 1
	@CardSchemaUId = UId,
	@PageCaption = Caption
FROM SysSchema
WHERE Name = @EditPageName
	AND ExtendParent = 0;
IF @SysEntitySchemaUId IS NULL
	THROW 50002, 'Entity not found. Check @EntityName input parameter.', 1;
IF @SectionSchemaUId IS NULL
	THROW 50002, 'Section page not found. Check @SectionPageName input parameter.', 1;
IF @CardSchemaUId IS NULL
	THROW 50002, 'Edit page not found. Check @EditPageName input parameter.', 1;
 
Select TOP 1
	@SysModuleEntityId = Id
From SysModuleEntity
Where SysEntitySchemaUId = @SysEntitySchemaUId
 
if (@SysModuleEntityId IS NULL)
BEGIN
	SELECT @SysModuleEntityId = NEWID()
	INSERT INTO SysModuleEntity (
		Id,
		SysEntitySchemaUId)
	VALUES (
		@SysModuleEntityId,
		@SysEntitySchemaUId
	);
END
 
Select TOP 1
	@SysModuleEditId = Id
From SysModuleEdit
Where SysModuleEntityId = @SysModuleEntityId
 
IF @SysModuleEditId IS NULL
BEGIN
	SELECT @SysModuleEditId = NEWID()
	INSERT INTO SysModuleEdit (
		Id,
		SysModuleEntityId,
		CardSchemaUId,
		UseModuleDetails,
		ActionKindCaption,
		ActionKindName,
		PageCaption)
	VALUES (
		@SysModuleEditId,
		@SysModuleEntityId,
		@CardSchemaUId,
		1,
		'New',
		@ActionKindName,
		@PageCaption
	);
END
INSERT INTO SysModule (
	Id,
	Caption,
	Code,
	SectionSchemaUId,
	SysModuleEntityId,
	CardSchemaUId,
	FolderModeId,
	SectionModuleSchemaUId,
	CardModuleUId,
	Image32Id)
VALUES (
	@SysModuleId,
	@SectionCaption,
	@EntityName,
	@SectionSchemaUId,
	@SysModuleEntityId,
	@CardSchemaUId,
	-- 'B659D704-3955-E011-981F-00155D043204', -- Use multiple folder
	'A24A734D-3955-E011-981F-00155D043204', -- Do not use folder
	'DF58589E-26A6-44D1-B8D4-EDF1734D02B4',
	'4E1670DC-10DB-4217-929A-669F906E5D75',
	'026742D9-390C-4778-BC46-9FA85C42677A'
);
SELECT
	@SysModuleId AS SysModule,
	@SysModuleEntityId AS SysModuleEntity,
	@SysModuleEditId AS SysModuleEdit;
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber,
		ERROR_MESSAGE() AS ErrorMessage;
IF @@TRANCOUNT > 0
	ROLLBACK TRANSACTION;
END CATCH;
IF @@TRANCOUNT > 0
	ROLLBACK TRANSACTION;



 

Hi, 

I followed the above steps . But there was no section created in any any of the workspace. Kindly suggest how to create new menu /section for the existing object.

Sriraksha KS,

Firstly, we highly do not recommend to create several sections per one object. Please note, that data will be duplicated in both sections, since they are referring to one object. You can create a new object in the system with the same range of columns and copy data from initial object to newly created. 

Nevertheless, if you intend to add section manually, please take a look at following tables: 

SysModule,

SysModuleEdit,

SysModuleEntity, 

SysModuleInWorkplace, 

SysSchema

 

Regards,

Anastasia

Does this still work for Freedom UI? Or is a new process required for achieving the same result now?

Harvey Adcock,

 

No, for Freedom UI sections, use the Freedom UI designer, which allows creation of sections for existing objects.

Show all comments