Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

AX PASS MULTIPLE PARAMETER FROM ONE TO OTHER

Posted on by Microsoft Employee

Hi 

I am able to pass single parameter from one form to other from the below code.Please send the code to pass multiple parameter using the below method.

void clicked()

{

 

    Args            _args;

    FormRun         _formRun;

    ItemRelation      _ItemRelation;

    AccountNum       _accountnum;

    PriceDiscAdmTrans apricediscadmtrans;

;

 

    _ItemRelation = PriceDiscAdmTrans.ItemRelation;

    _accountnum = PriceDiscAdmTrans.AccountRelation;

    apricediscadmtrans = pricediscadmtrans_ds.getFirst(true);

   

    _args = new Args();

    _args.name(formstr(GACC_PurchPriceHist)); 

    _args.caller(this);

    _args.parm(_ItemRelation);

    _args.parm(_accountnum);

    _args.record(PriceDiscAdmTrans);

    _formRun = ClassFactory.formRunClass(_args);

    _formRun.init();  

    _formRun.run(); 

    _formRun.wait();

    _args.parmObject( _args );

 

}

 

 

public void init()

 

{

    Query                   query;

    QueryRun                queryRun;

    QueryBuildDataSource    qbds;

    QueryBuildRange         qbr,qbr1;

        ;

    switch(element.args().dataset

{

 

case tablenum(PriceDiscAdmTrans): 

{

    _ItemRelation = element.args().parm();

    _accountnum = element.args().parm();

 

    query   = new Query();

    qbr = query.addDataSource(tablenum(PriceDiscAdmTrans)).addRange(fieldnum(PriceDiscAdmTrans,ItemRelation));

    qbr1 = query.addDataSource(tablenum(PriceDiscAdmTrans)).addRange(fieldnum(PriceDiscAdmTrans,AccountRelation));

   

    info(PriceDiscAdmTrans.getSQLStatement());

    PriceDiscAdmTrans_ds.query(query); // execution of the query

break;

    }

}

super();

 

}

 

Thanks

 

 

 

 

*This post is locked for comments

  • Verified answer
    RE: AX PASS MULTIPLE PARAMETER FROM ONE TO OTHER

    Well, you can use args.parmObject(), generally speaking, or just reference a specific method on the caller, that would return a container or whatever collection object you want, and invoke it from the called form through element.args().caller().

    However, in your case, you pass in the record buffer PriceDiscAdmTrans, so maybe you can just rely on element.args().record() in the called form to get the two field values?

    Through the map, it could look like this:

       Map filters = new Map(Types::Int64, Types::String);

       Args args = new Args();

       filters.insert(fieldNum(PriceDiscAdmTrans, ItemRelation), 'some value');

       filters.insert(fieldNum(PriceDiscAdmTrans, AccountRelation), 'some 33');

       args.name(formStr(Form1));

       args.parmObject(filters);

    Note, however, that passing in object references is usually more error-prone than value types.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans