Pass value from one form to another form (Form Type is class)

Want to pass value from one form to another. using click button

void clicked()
{
    Args args;
    FormRun formRun;
    ;
    args = new Args();
    args.parm(KMVirtualNetworkAnswerTable_kmVirtualNetworkAnswerTableId.valueStr());
    args.caller(this);
    New MenuFunction(MenuItemDisplayStr(KMQuestionnaireSelection),MenuItemType::Display).run(args);    formRun.init();
    formRun.init();
    formRun.run();
    formRun.wait();
   
    super();
}

Open the questionnaire complete form but cannot filter the value with below error.

Error is :-

Error executing code: FormRun object not initialized.

(C)\Classes\FormRun\init
(C)\Classes\FormButtonControl\Clicked - line 15

When are you init the form?

formRun = new FormRun()

but I think you have another problem why do you need formRun if you are calling KMQuestionnaireSelection form using menuItem.

Yes you are right now I change the code like this;

void clicked()
{
Args args;
FormRun formRun;
;
args = new Args();
args.parm(KMVirtualNetworkAnswerTable_kmVirtualNetworkAnswerTableId.valueStr());
args.name(formstr(“KMQuestionnaireList”));
formRun = new Formrun(args);
formRun.init();
formRun.run();
formRun.wait();
super();
}
By this code I can open the form and filter the value but I need to open menu item and filter the value.

You can use MenuFunction

already tried with this code but this will only open the form from menu item but didn’t not filter the value.

args.caller(this);

New MenuFunction(MenuItemDisplayStr(KMQuestionnaireSelection),MenuItemType::Display).run(args);

It should work unless you are not passing the args properly.

In the opened form you need to recover parm using element.args()…

Example:

On the init method you can recover your values

str s = element.args().parm();

init method:-
if (element.args().parm())
{
kmVirtualNetworkAnswerTableId = element.args().parm();
}

still it is not filtering the value.

Also put executeQuery on form datasource
public void executeQuery()
{
this.query().dataSourceTable(tablenum(KMTmpQuestionnaireList)).addRange(fieldnum(KMTmpQuestionnaireList,kmVirtualNetworkAnswerTableId)).value(kmVirtualNetworkAnswerTableId);
super();
}