Invoke #AVFRAMEWORKMANGER.avSwitch from a Non-command handler reusable part?
Posted: Tue Feb 20, 2018 8:43 am
I have a reusable part that exists in several different command handlers. The resuable part acts as a common "header area" for the various command handlers. I attempted to add a button in this reusable part that when clicked, would perform an avSwitch to initiate a filter associated with an entirely different business object (see code at bottom).
However, when I attempted to run it I received an error,
"Fatal Error: Cannot read property 'mthAVSWITCH' of null
Location: Reusable Part: OC_RP_Command_OppHeader, line 382
Call Stack: 1. Evtroutine Handling(#LocButton.Click): OC_RP_Command_OppHeader, line 382
Reported By: oc_rp__2.js, line 4088:38"
After reading the Lansa documentation on the use of avSwitch, I'm wondering if I can even do this? Can the avSwitch only be initiated by true command handlers?
http://docs.lansa.com/14/en/lansa048/in ... Ref4558516 -
"This service allows your filters and command handlers to switch control between different business objects and to execute commands at the Framework, application or business object level.The switching service is invoked by using method #avFrameworkManager.avSwitch with the appropriate parameters. "
** CODE IN NON-COMMAND HANDLER REUSABLE PART.
Evtroutine Handling(#LocButton.Click)
#AVFRAMEWORKMANAGER.avSwitch Caller(#COM_OWNER) Toobjectnamed(LOCATIONS)
#Timer1.Interval := 1000
#Timer1.Start
Endroutine
Evtroutine Handling(#Timer1.Tick)
#Timer1.Stop
* Initiate the Location Filter reusable part and cause it to display the Location for this opportunity.
* The "To" parameter should be "APPLICATION" (rather than "BUSINESSOBJECT") in this case because we want to signal this event to the OPPORTUNITY BUSINESS
* OBJECT and NOT the Business object that this command handler is associated with (Locations).
* See "avEvent" Event routine in the Location Filter reusable part.
#COM_OWNER.avSignalEvent Withid(OneLoc) To(APPLICATION) Sendainfo1(#OC01_Company) Sendainfo2(#OC01_LocationID)
#COM_SELF.avCloseForm
Endroutine

However, when I attempted to run it I received an error,
"Fatal Error: Cannot read property 'mthAVSWITCH' of null
Location: Reusable Part: OC_RP_Command_OppHeader, line 382
Call Stack: 1. Evtroutine Handling(#LocButton.Click): OC_RP_Command_OppHeader, line 382
Reported By: oc_rp__2.js, line 4088:38"
After reading the Lansa documentation on the use of avSwitch, I'm wondering if I can even do this? Can the avSwitch only be initiated by true command handlers?
http://docs.lansa.com/14/en/lansa048/in ... Ref4558516 -
"This service allows your filters and command handlers to switch control between different business objects and to execute commands at the Framework, application or business object level.The switching service is invoked by using method #avFrameworkManager.avSwitch with the appropriate parameters. "
** CODE IN NON-COMMAND HANDLER REUSABLE PART.
Evtroutine Handling(#LocButton.Click)
#AVFRAMEWORKMANAGER.avSwitch Caller(#COM_OWNER) Toobjectnamed(LOCATIONS)
#Timer1.Interval := 1000
#Timer1.Start
Endroutine
Evtroutine Handling(#Timer1.Tick)
#Timer1.Stop
* Initiate the Location Filter reusable part and cause it to display the Location for this opportunity.
* The "To" parameter should be "APPLICATION" (rather than "BUSINESSOBJECT") in this case because we want to signal this event to the OPPORTUNITY BUSINESS
* OBJECT and NOT the Business object that this command handler is associated with (Locations).
* See "avEvent" Event routine in the Location Filter reusable part.
#COM_OWNER.avSignalEvent Withid(OneLoc) To(APPLICATION) Sendainfo1(#OC01_Company) Sendainfo2(#OC01_LocationID)
#COM_SELF.avCloseForm
Endroutine