Search code examples
microsoft-dynamicsdynamics-ax-2012

AX2012: Capture SysInfoAction on form initialization


Situation: I am opening a form via a SysInfoAction (SysInfoAction_FormrunQuery to be exact) from an error message (info log) as follow (Compressed a bit):

query.addDataSource(tableNum(WDPErrorLogView)).addRange(fieldNum(WDPErrorLogView, ErrorOutboundMessage)).value(SysQuery::value(resultRecId));
error("@WDP1299", '', SysInfoAction_FormrunQuery::newFormnameQuery(formStr(WDPErrorLog), query));

Problem: The form I am calling here, has multiple tabs, since it can be opened with queries from various tables. I would like to capture this calling record to not only filter on the record passed (This already happens thanks to the SysInfoAction), but also make the appropriate tab page active.

I thought that element.args().record() would contain this calling record, but to my surprise it does not. Any ideas how to could get hold of this record... or, at least its table id?


Solution

  • This is easy. Just add a parmMethod for an object/caller to \Classes\SysInfoAction_FormrunQuery. Copy the static method newFormnameQuery and call it newFormnameQueryWithCaller for example and then add an extra argument, then set that argument in your parm method with the same style as newFormnameQuery.

    Then in your \Classes\SysInfoAction_FormrunQuery\run, where it sets up the args record, just add args.caller(...) and set your caller object if it exists.