Submenu Item Of Button

Hi,

I'm working on a Button component in Case Module that contains submenu 

Button's Source Code:

 

Submenu's Source Code:

 

In the source code, Currently fetching these submenus individually using Localizable String as the following:

let ActionBtnSubmenu= [
                               await request.$context.Resources.Strings.MenuItem_ll5to4b_caption,
                               await request.$context.Resources.Strings.MenuItem_ilbm7ox_caption,
                               await request.$context.Resources.Strings.MenuItem_aou2m8v_caption,
                            ];

Is there a way to retrieve these submenu items as an array— defined collectively in the DemoActionButton detail or elsewhere—so that I don’t have to fetch them one by one?

 

Platform: Creatio:Energy (Freedom UI)

Like 0

Like

1 comments
Best reply

Hello Souresh,

 

Unfortunately there is no such property in request.$context that contains all submenu items that belong to some specific button.

If you want to get the submenu items as an array without fetching them one by one you can use the following approach

const menuItems = Object.entries(request.$context.resources.strings)
	.filter(([key, _]) => key.includes("MenuItem_"))
	.map(([_, value]) => value);

or if you have other buttons with submenu items on your page you should use other filtering condition to get only the menu items that belong to the correct button.

const menuItems = Object.entries(request.$context.resources.strings)
	.filter(([key, _]) => key.includes("_ll5to4b") || key.includes("_ilbm7ox") || key.includes("_aou2m8v"))
	.map(([_, value]) => value);


As other option you can create a separate module to store the array with menu items data and then use that array. But in this case you will have to be attentive and not forget to modify this module in case of changes in the designer.

 

Hello Souresh,

 

Unfortunately there is no such property in request.$context that contains all submenu items that belong to some specific button.

If you want to get the submenu items as an array without fetching them one by one you can use the following approach

const menuItems = Object.entries(request.$context.resources.strings)
	.filter(([key, _]) => key.includes("MenuItem_"))
	.map(([_, value]) => value);

or if you have other buttons with submenu items on your page you should use other filtering condition to get only the menu items that belong to the correct button.

const menuItems = Object.entries(request.$context.resources.strings)
	.filter(([key, _]) => key.includes("_ll5to4b") || key.includes("_ilbm7ox") || key.includes("_aou2m8v"))
	.map(([_, value]) => value);


As other option you can create a separate module to store the array with menu items data and then use that array. But in this case you will have to be attentive and not forget to modify this module in case of changes in the designer.

 

Show all comments