[RPG] Offline System Menus

Please do not use to report errors- use your regional help desk.
Please mark posts as being for RPG or RDMLX (LANSA) developer.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
mwilliams
Posts: 17
Joined: Thu May 18, 2017 10:34 am

[RPG] Offline System Menus

Post by mwilliams » Wed May 31, 2017 2:38 pm

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
  );
}

tsupartono
Posts: 289
Joined: Tue Apr 17, 2012 7:21 pm

Re: [RPG] Offline System Menus

Post by tsupartono » Fri Jun 02, 2017 7:14 am

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).

mwilliams
Posts: 17
Joined: Thu May 18, 2017 10:34 am

Re: [RPG] Offline System Menus

Post by mwilliams » Fri Jun 02, 2017 11:14 pm

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.

tsupartono
Posts: 289
Joined: Tue Apr 17, 2012 7:21 pm

Re: [RPG] Offline System Menus

Post by tsupartono » Mon Jun 05, 2017 1:15 am

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
Attachments
TestMenu.zip
(2.41 KiB) Downloaded 53 times

mwilliams
Posts: 17
Joined: Thu May 18, 2017 10:34 am

Re: [RPG] Offline System Menus

Post by mwilliams » Mon Jun 05, 2017 11:57 am

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.
Attachments
screenshot.png
screenshot.png (45.43 KiB) Viewed 1994 times

tsupartono
Posts: 289
Joined: Tue Apr 17, 2012 7:21 pm

Re: [RPG] Offline System Menus

Post by tsupartono » Tue Jun 06, 2017 4:18 am

Use Form.Menus instead of System.Menus for form level menu items.

Post Reply