It is possible to attach event listeners to objects in X++.
The next code sample shows the usage of the SysEventBroker and SysEventInfo classes to handle events :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | static void SysEventTest(Args _args) { SysEventBroker broker = SysEventBroker::construct(); SysEventInfo info1 = new SysEventInfo("Info-1"); // catch all; SysEventInfo info2 = new SysEventInfo("Info-2"); // catch specific class SysEventInfo info3 = new SysEventInfo("Info-3"); // catch specific type ; // Setup broker.addListener(info1, classNum(Object)); broker.addListener(info2, classNum(Runbase)); broker.addListener(info3, classNum(Object), "Fire 2"); // catch Fire 2 broker.addListener(info3, classNum(Object), "Fire 4"); // and Fire 4 broker.fireEvent(classNum(CustAutoCreate), "Fire 1", "This is my life"); broker.removeListener(info2, classNum(Runbase)); broker.fireEvent(classNum(CustAutoCreate), "Fire 2", "this is my time"); broker.fireEvent(classNum(CustAutoCreate), "Fire 3", "just show me the light"); broker.removeListener(info1); broker.fireEvent(classNum(CustAutoCreate), "Fire 4", "and I go there"); } |
Hi,
Strange if this applies to Ax 2009 – I did not find the class at all in our installation.
Harri