Handheld Menu Issue

I’ve tried 2 ways to add an item to the HH menu - both work, in that the menu item appears and works for the first time of asking.

Method 1
Using customisation and reflection to add the items

Method 2
Inserting into the Erp.MESMenu table

Both instances call a menu ID called “HHCSPUT”, which is setup in Process Calling Maintenance to run with a customisation layer. The first time you load the HH menu and click on it you get the correct customised screen - but if you come out of that screen and go to another, then come back - it only displays the base form without customisation.

You then have to fully exit HH and start it again to be able to use the screen 1 time.

Any ideas why Process Calling isn’t always kicking in?

I done something like this in the past

private void HHMenuForm_Load(object sender, EventArgs args)
    {
        // Add Event Handler Code
        var view = oTrans.Factory("MESMenu");
        var menuItem = view.dataView.AddNew();
        menuItem.BeginEdit();
        menuItem["MESMenuID"] = 177;
        //menuItem["IsMenu"] = true ;
        menuItem["Hidden"] = false;
        menuItem["CurrentEmpAllowed"] = true;
        menuItem["MenuType"] = "H";
        menuItem["ParentMESMenuID"] = 1;
        menuItem["TranslateMenuDesc"] = "Chris";
        menuItem["Company"] = ((Ice.Core.Session)oTrans.Session).CompanyID;
        menuItem.EndEdit();
 
        var menuItem2 = view.dataView.AddNew();
        menuItem2.BeginEdit();
        menuItem2["MESMenuID"] = 178;
        //menuItem["IsMenu"] = true ;
        menuItem2["Hidden"] = false;
        menuItem2["CurrentEmpAllowed"] = true;
        menuItem2["MenuType"] = "H";
        menuItem2["ParentMESMenuID"] = 177;
        menuItem2["MenuID"] ="HHMN1001";
        menuItem2["TranslateMenuDesc"] = "ChrisSub";
        menuItem2["Company"] = ((Ice.Core.Session)oTrans.Session).CompanyID;
        menuItem2.EndEdit();
 
        var menuCall = HHMenuForm.GetType().GetMethod("showMenu",  BindingFlags.Instance | BindingFlags.NonPublic,null,CallingConventions.Any,  new Type[]{typeof(int)}, null);
        menuCall.Invoke(HHMenuForm,new object[]{1});
    }
``

That code looks VERY familiar - it’s the code that I refer to in my “Method 1” above. Problems I’ve experienced with that way of doing it - when logging out one user and logging another in, it comes up saying that it’s a duplicate Menu ID. I then end up with 7 and 8 on the main menu. It also has the same issue, loads the customisation layer the first time (so against HHMN1001 in your example, using Process Calling Maintenance), then not on subsequent times until closing all of the way out of HH and restarting.

Could you try a customisation for me and see what it does? :slight_smile:

It will have to be this evening, I am super swamped. What version are you on? I wonder if it could be it related specifically to ProcessCallerMaint?

One thing I’d verify is that the actual MESMenu table is stock. That could also potentially be the source of the dupe error. I do remember there was a lot of trial and error before I got it working but the code above seemed to work…eventually.

Yeah the issue is only with the customised layer not being shown really. I’ve found it more reliable to insert rows into the MESMenu table, and no longer get the duplicate issue.

If you could test that would be awesome :+1: I am on 10.2.300.15

Much appreciated,

Mark

I like that too. I do some magic with Menu.GetRows Method Directive etc, too. Cleaner I think.

Did either of you 2 legends have any ideas why Process Calling works for the first time, then doesn’t work (calls base form not customisation) again until you restart the HH?

I’ve seen a lot of issues with the cache folder on handheld RDP servers. Usually have to delete the actual folder and not just clear cache

It does the same on my desktop too within the full smart client.

Finally solved this…! The custom code that you see here was created by CSG - and I realised that an adapter was being created but never destroyed. Once I added in the highlighted line of code to destroy it, it started behaving properly and always showing the customised layer not the base!