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)

Using args passing multiple field to form

(0) ShareShare
ReportReport
Posted on by

Hi all, I want to ask how to pass multiple fields to form?

example in FormA :

Args args;
FormRun formrun;
;

args = new args();
args.parm(_salesid);
args.parm(_itemid);
args.parm(_costtransrefid);
args.name(formStr(FormB));
formrun = classFactory.formRunClass(args);
formrun.init();
formrun.run();
formrun.wait();

FormB:

void initvlaues()

{

salesidparm = element.args().parm();
itemidparm = element.args().parm();
transrefidparm = element.args().parm();

info(strFmt("%1", salesidparm));
info(strFmt("%1", itemidparm));
info(strFmt("%1", transrefidparm));

}

the problem is the infolog only show the _costtransrefid value, how to pass multiple value to each variable in formB? because I'll need it as query range filter in formB 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    You can create data contract class something like:

    MyContractClass

    {
      int a;
      int b;
         ....
    
      public int parmA(int _a = a)
      {
         a = _a;
         return a;
      }
    
      public int parmB(int _b = b)
      {
         b = _b;
         return b;
      }
    ... }


    and change you example 

    Args args;
    FormRun formrun;
    ;
    args = new args();
    MyContractClass contract = new MyContractClass();
    
    contract.parmA(a);
    contract.parmB(b);
    args.parmObject(contract);
    
    args.name(formStr(FormB));
    formrun = classFactory.formRunClass(args);
    formrun.init();
    formrun.run();
    formrun.wait();
    FormB:
    void initvlaues()
    {
    MyContractClass contract = element.args().parmObject() as MyContractClass;
    a = contract.parmA();
    b = contract.parmB();
    }


    Also you can use container instead of contract class, but I prefer contracts because they explicitly specifies number of parameters and types. 

  • Verified answer
    Rudi Hansen Profile Picture
    4,075 on at

    Do like ievgen sugests, you have to remember that what you are trying to do with giving args.parm tree values like you do is the same as having a variable and assigning it tree different values, it will then only have the last value you set it to, like this.

    int myVar;
    
    myVar = 5;
    myVar = 15;
    myVar = 20;
    
    print myVar; // Outputs 20


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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans