I am calling a class through a menuItem in GlobalToolsMenu. The caller of my args is always null altough it is called from a form.
Is there a way to transmit the form as caller?
I am calling a class through a menuItem in GlobalToolsMenu. The caller of my args is always null altough it is called from a form.
Is there a way to transmit the form as caller?
Copyright © 2021 Jogjafile Inc.
When you are opening a menu item from
GlobalToolsMenu
it isn't associated with the current form, it works as if you are trying to open a menu item from an independent menu. If you need to get access from the called class to the current form you need to use some workaround.E.g. you can try calling
WinAPI::getForegroundWindow()
from your class to retrieve a handle to the foreground window (the AX form with which the user is currently working). Having the handle, you need to find a correspondingFormRun
object. For that purpose you can try customizing\Classes\SysSetupFormRun\init
to keep a map with relations between form handles and theFormRun
objects ininfolog.globalCache()
. Then you can use that cached map in your class to get theFromRun
object from the retrieved handle.