Page 1 of 1
[RPG] Offline System Menus
Posted: Thu Jun 01, 2017 5:38 am
by mwilliams
Is it possible to control the visibility of a form's menu item in an offline app? I tried the following and it didn't work.
Code: Select all
initForm = function () {
this.lrexec(
function () {
this.q_setProperties({
"System.Menus.MOR3501_Edit.Hidden": "True"
});
},
null
);
}
Re: [RPG] Offline System Menus
Posted: Fri Jun 02, 2017 10:14 pm
by tsupartono
Yes you can definitely change the menu item visibility from the local script.
For example, using the ECL script below, I can hide and show the "Human Resources" menu (HRA_MENU) in the longrangedemo.lxp schema.
Code: Select all
hideMenuItem = function ()
{
lrexec(
function ()
{
this.q_setProperty("System.Menus.HRA_MENU.Hidden", "Y");
this.console("Menu item HRA_MENU set to HIDDEN");
}
);
};
showMenuItem = function ()
{
lrexec(
function ()
{
this.q_setProperty("System.Menus.HRA_MENU.Hidden", "N");
this.console("Menu item HRA_MENU set to VISIBLE");
}
);
}
Make sure that the 'MOR3501_Edit' is a valid symbolic name of the menu item (instead of the form/target that the menu item points to).
Re: [RPG] Offline System Menus
Posted: Sat Jun 03, 2017 2:14 pm
by mwilliams
Ok, well I'm obviously missing something. If I set the hidden properly in my rpg program and refresh my schema, then the menu item is not visible, but if I do it in a local script when the form loads nothing happens. It stays visible. I know I'm using the right symbolic name because I'm attaching a script function to the onclick property plus like I said before if I hard code it to hidden in the rpg it becomes hidden.
I've even added a button to the form which runs the example function you sent only replacing the symbolic name.
Re: [RPG] Offline System Menus
Posted: Mon Jun 05, 2017 4:15 pm
by tsupartono
To make sure we are talking about the same thing, I have included here a test package that hide/show a menu item using ECL.
The attached ZIP file (see below TestMenu.zip) contains a schema (MenuTest.lxp), a resource JS file, and an RPG program. Copy the schema and resource to their respective folders in LongRange, and compile the TSLRNG005 RPG program.
The schema contains 3 menu items:
- Test Menu Item 1
- Test Menu Item 2
- Show/Hide
Tap the "Show/Hide" menu item to execute the TSLRNG005 RPG program.
This program creates a form whose OnLoad event hides a menu item (
Test Menu Item 1).
After executing this, you should no longer see the
Test Menu Item 1
Try out also the Show & HIde button on the form to see if they work for you
Re: [RPG] Offline System Menus
Posted: Tue Jun 06, 2017 2:57 am
by mwilliams
what you sent worked.
I misspoke when I said system menu. I meant more of a form level menu. What I'm trying to do is limit the form level menu options based upon a mode. If the user is in a maintenance type mode, then options like edit/save would be visible. If they are in an inquiry type mode, then save/edit would be invisible.
I've attached a screen shot and circled exactly what I'm trying to hide. Sorry for the wild goose chase.
Re: [RPG] Offline System Menus
Posted: Tue Jun 06, 2017 7:18 pm
by tsupartono
Use Form.Menus instead of System.Menus for form level menu items.