web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Suggested Answer

Passing value from one form to another form

(0) ShareShare
ReportReport
Posted on by

By this code I can open the form and filter the value but I need to open menu item and filter the value.

Click button:


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();
 }




Second form:-


init method:


 if (element.args().parm())
    {
    kmVirtualNetworkAnswerTableId = element.args().parm();
    }

executeQuery on form datasource 

public void executeQuery()
{

    this.query().dataSourceTable(tablenum(KMTmpQuestionnaireList)).addRange(fieldnum(KMTmpQuestionnaireList,kmVirtualNetworkAnswerTableId)).value(kmVirtualNetworkAnswerTableId);

    super();
}

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    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);

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    It is because your code is wrong. You need to pass in args.record(), and not the parm, then check for that in the initialization of the form.

    http://stackoverflow.com/questions/15756225/how-to-invoke-a-menu-item-from-code-in-ax-2012

  • Shashikant1237 Profile Picture
    5 on at

    Form one

    public void clicked()

    {

    Args arg = new Args(); F

    frmRun;

    super();

    arg.name(formStr(SkillMayArgsTwo));// Form Name

    arg.record(VendTable_ds.cursor()); // Heiglited record

    arg.parm("Test");

    frmRun= classFactory.formRunClass(arg);

    frmRun.init();

    frmRun.run();

    frmRun.detach();

    }

    Form two

    public void init()

    {

    super();

    if(element.args().record())

    {

    Info(strFmt("%1",vendTable.AccountNum)); 

    }

    [quote user="alikhan_3"]

    By this code I can open the form and filter the value but I need to open menu item and filter the value.

    Click button:
    
    
    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();
     }
    
    
    
    
    Second form:-
    
    
    init method:
    
    
     if (element.args().parm())
        {
        kmVirtualNetworkAnswerTableId = element.args().parm();
        }
    
    executeQuery on form datasource 
    
    public void executeQuery()
    {
    
        this.query().dataSourceTable(tablenum(KMTmpQuestionnaireList)).addRange(fieldnum(KMTmpQuestionnaireList,kmVirtualNetworkAnswerTableId)).value(kmVirtualNetworkAnswerTableId);
    
        super();
    }
    
    [/quote]

    [quote user="alikhan_3"]

    By this code I can open the form and filter the value but I need to open menu item and filter the value.

    Click button:
    
    
    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();
     }
    
    
    
    
    Second form:-
    
    
    init method:
    
    
     if (element.args().parm())
        {
        kmVirtualNetworkAnswerTableId = element.args().parm();
        }
    
    executeQuery on form datasource 
    
    public void executeQuery()
    {
    
        this.query().dataSourceTable(tablenum(KMTmpQuestionnaireList)).addRange(fieldnum(KMTmpQuestionnaireList,kmVirtualNetworkAnswerTableId)).value(kmVirtualNetworkAnswerTableId);
    
        super();
    }
    
    [/quote]

    }

  • nmaenpaa Profile Picture
    101,162 Moderator on at

    Normally you don't need to write any code to filter by the caller record. Just make sure that you have defined your table relations properly (for example look how SalesLine and SalesTable are related by a relation in SalesLine table).

    But if you just want to pass this string in the parm() of menu item, do it like this (in the clicked method):

     Args args;
     MenuFunction menuFunction = new MenuFunction(menuItemDisplayStr(myMenuItemName));
     ;
     args = new Args();
     args.parm(KMVirtualNetworkAnswerTable_kmVirtualNetworkAnswerTableId.valueStr());
     args.caller(element);
     menuFunction.run(args);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans