Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

passing values using Args() class

Posted on by 61


Args.JPG
Hi all ...
I am just trying to send a string from Form1 to Form2 by clicking on button on Form1
after I make some search on the internet, I found this approach that sending and opening the Form2
about me I don't want Form1 open Form2 because Form2 already opened, and I want Form2 receive the value automatically
Help please.

  • 365 financial Profile Picture
    365 financial 61 on at
    RE: passing values using Args() class

    thanks a lot..

    it is done

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 225,610 Super User on at
    RE: passing values using Args() class

    You can use a method and pass the value through a method parameter. For example:

    FormRun callerForm = element.args().caller();
    callerForm.myMethod(strEdt2.text());

  • 365 financial Profile Picture
    365 financial 61 on at
    RE: passing values using Args() class

    ok martin now if I get the caller of the parent form how can i pass for example a string value from child form to the parent

    can you give me some lines of code please

  • Martin Dráb Profile Picture
    Martin Dráb 225,610 Super User on at
    RE: passing values using Args() class

    That sounds easy. You should be able to get a reference to the main form by calling element.args().caller().

  • 365 financial Profile Picture
    365 financial 61 on at
    RE: passing values using Args() class

    Ok I have a form with a grid that read a one row of data from a DataSource, in this form there is a button when I press it a new form is opened this form contain:

    1- string edit value that comes from another DataSource

    2- OK button

    So, when I press the OK Button the value in the string edit must be passed to a field in a DataGrid of the main form.

    I hope that is clear

  • Martin Dráb Profile Picture
    Martin Dráb 225,610 Super User on at
    RE: passing values using Args() class

    Well, how do you intend to determine which form your want to update? I can have multiple instances of Form2 running (or none). And you don't have a reference to any of them.

    Let's let's forget implementation details for now. Instead, tell us what business requirement you're trying to implement.

  • 365 financial Profile Picture
    365 financial 61 on at
    RE: passing values using Args() class

    Thank u Girish Your response was helpful

  • 365 financial Profile Picture
    365 financial 61 on at
    RE: passing values using Args() class

    thanks Martin for your response and I changed the title of this thread. Yes, the two forms don't relate to each other so what is the design that I should to have?

  • GirishS Profile Picture
    GirishS 27,828 Super User on at
    RE: Args() class issue

    In addition to Martin comments, it seems that you are using string control for both the forms, So its not possible to pass value from first form to second form if it is not called from the first form.

    If the string control is table level field you can update the string value entered in form 1 table to form 2 table. But you need to press F5 to see the data in the Form 2.

    Thanks,

    Girish S.

  • Martin Dráb Profile Picture
    Martin Dráb 225,610 Super User on at
    RE: Args() class issue

    If you Form1 has a reference to the FormRun object of Form2 (e.g. because it was open from Form1), you can simply calls a method of Form2 and pass the value there. If you just have two forms that aren't aware of each other, the task isn't easy and you should rather come with a different design.

    Note that it's not "Args class issue" in either case, therefore you should rather update the title of this thread.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,995 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,610 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans