Data backstamping from form to caller class

Hi All,

Thank you for reading the post, I have a class which calls a form through menuItem, the form does some processing and derives value(s), now I want to capture/ use that value(s) in the calling class (or pass the values to the calling class). How can I achieve that?

cache the values in form and use the cache in returned class.

hi dear,

just try this,

static void main(Args args)

{

;

if (args && args.record())

{

info(“args is populated”);

info(args.menuItemName());

rec = args.record();

info(tableid2name(args.record().TableId));

pause;

}

else

{

info(“args is empty”);

}

}

Hi Abhinay,

You can pass value from form to class through Args like this,

MenuFunction mf;
args args = new Args();
;

args.record(EmplTable);

mf = new menufunction(identifierstr(DASEmplDuplication), MenuItemType::Action);
mf.run(args);

in the main() method

EmplTable localEmplTable;
;

if(args.record().TableId == tablenum(EmplTable))
localEmplTable = args.record();

A common pattern to catch args.caller() in form init() method, validate it (e.g. if (SysDictClass::is(args.caller(), classNum(MyClass))) and save to a strongly-typed member variable (e.g. MyClass myClass). Then, to set some data to the class requires just to call one or more methods (e.g. myClass.parmXyz(…)).

Hi,

Please accept my apologies for the for the late reply, I was away for the last few days.

This is how I got it done

static void TestJob(Args _args)
{ Args args = new Args();
FormRun formRun;
;
args.name(formstr(FormTest));
formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
info(args.parm());
}

And in the form I just had to use args anywhere I needed to set value(s)

element.args().parm(‘Test successful!’);