Enable (disable) menu item from an application

Hi all,

Can anyone shed some light on a way to handle this usecase.

The user logs in and the default state of one of the menu items (item_37) is disabled. The code in the menu application’s onApplicationInit is simply:

if (empty([srv_id])) {
	sc_menu_disable(item_37);
	}
else {
  sc_reset_menu_disable();
}

No problem at this time (see pic)

disabled_menu_item

Next, when the user selects the “Open Blueprint” menu item it redirects to a grid application where they can select a record (see pic)

disabled_menu_item_grid_app

When the user selects a record (link) they go to a form application and it is at this time that I set the global variable [srv_id]. Now, it’s also at this time I want to change the “Close Blueprint” (menu item_37) to enabled so I have tired using the same code logic on the form application’s onApplicationInit but it results in a script error (see below).

Fatal error: Uncaught Error: Call to undefined function sc_reset_menu_disable() in C:\Program Files (x86)\NetMake\v9-php73\wwwroot\scriptcase\app\e360SDB\form_update_service_design\form_update_service_design_apl.php:467 Stack trace: #0 C:\Program Files (x86)\NetMake\v9-php73\wwwroot\scriptcase\app\e360SDB\form_update_service_design\form_update_service_design_apl.php(1255): form_update_service_design_apl->ini_controle() #1 C:\Program Files (x86)\NetMake\v9-php73\wwwroot\scriptcase\app\e360SDB\form_update_service_design\index.php(2353): form_update_service_design_apl->controle() #2 {main} thrown in C:\Program Files (x86)\NetMake\v9-php73\wwwroot\scriptcase\app\e360SDB\form_update_service_design\form_update_service_design_apl.php on line 467

It’s obvious to me that I can’t reference the menu item or sc_reset_menu_disable(); in another application other than from within the menu application. Is that correct? If so, does anyone have any suggestion on a work around for this business logic?

Thanks muchly in advance :slight_smile:

Correct…menu item able/disable is in the menu only. I have something similar. Menu items start disabled, they user opens a control app to make a selection and then based on global variables set there, menu items are made available. At the end of my control app I do an sc_redir to the menu. Globals have been set so the items available in the menu are different now.

I often have trouble with functions in that event. Have you tried a different event?

Thanks @mollyshark. I’m currently playing with a JavaScript function that, hopefully, can update the menu from my child page. Outside of that, I’ll look at your approach, if I understand your meaning.

Perhaps have the CLOSE BLUEPRINT function within the blueprint app not the menu and don’t have as a menu item at all?

That’s precisely what I ended up doing @iosson. Mucking about with the menu to get it to work was taking up too much precious time. My solution was to place a very obvious ‘Close Blueprint’ button and it works fine.