Hello Dynamics Community,
I am trying to pass value from one class to another using Action Menu Item. Is there any way to achieve that?
For example,
class Class1 extends RunBase
{
AccountNum AccountNum;
#DEFINE.CurrentVersion(1)
#LOCALMACRO.CurrentList
AccountNum
#ENDMACRO
container pack()
{
return [#CurrentVersion,#CurrentList;
}
public boolean unpack(container _packedClass)
{
int version = conPeek(_packedClass,1);
switch (version)
{
case #CurrentVersion:
[version,#CurrentList = _packedClass;
break;
default:
return false;
}
return true;
}
public Object dialog()
{
Dialog dialog = super();
dialog.caption( 'Simple Dialog');
dialog.addMenuItemButton(MenuItemType::Action, 'ActionMenuItem1');
return dialog;
}
public void run()
{
info("Class1");
}
void setValue()
{
AccountNum = '4';
}
public AccountNum getAccountNum()
{
return AccountNum;
}
public static void main(Args _args)
{
Class1 class1 = new Class1();
class1.setValue();
if (class1.prompt())
{
class1.run();
}
}
}
class Class2 extends RunBase
{
public static void main(Args _args)
{
Class1 class1;
Object caller = _args.caller(); // To get the caller
class1 = caller.runBase(); // To get object of caller class
Info(strFmt("Value of AccountNum in Class1 : %1", class1.getAccountNum()));
}
public void run()
{
info("Hello");
}
}
I have Class1 and Class2 and one Action Menu Item for Class2. Now I am calling the menu item from the dialog method and would like to pass the value(in my case AccountNum) from Class1 to Class2.
Is there any way to achieve that? Please suggest.