Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

set up value to a form control

Posted on by Microsoft Employee

Hi, I want to set a form field value after doing a modification on another field in the same form. I've created a modify method to fill the second field automatically and I tried too many functions but the field is not filled when modifying the first one.

I want to know how to refer to fields from the same form using x++ code?

The value I want to set is a real value and I want it to be changed before creating the line int the table,  because some fields can't be modified after the

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: set up value to a form control

    Ok

    For Control1

    example

    public boolean modified()

    {

       boolean ret;

       real    value;

       ret = super();

       switch (Control1.selection())

       {

           case AccountingEventType::Cancel:

               value = 100;

               break;

           case AccountingEventType::Finalize:

               value = 1000;

               break;

           default:            

               value = Control1.selection();

       }

       Control2.realValue(value);

       element.redraw();

       return ret;

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: set up value to a form control

    Hi Grigory,

    I don't need to assign a value to the combo box, but to the next field after modifying the combo box . I'll try to explain more:

    I have two controls in  my form (control 1 and control 2).

    control 1 is a combo box that has two enums: enum1 and enum2, and the second control is a realEdit field.

    if i choose enum 1 in the combo box, control 2 displays  realValue1 automatically, if not, control 2 displays realValue2.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: set up value to a form control

    Hi!

    for example

    public boolean modified()

    {

       boolean ret;

       ret = super();

       ComboBox.selection(1);

       element.redraw();

       return ret;

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: set up value to a form control

    Hi Crispin,

    Yes that's what i'm doing. I tried to test with an info message and the table field is getting the right value but i'm having troubles with displaying it in the form instantly. What I need is quite simple: a function that allows me to assign a real value to a realEdit form control just after modifying the previous field (which is a combo box)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: set up value to a form control

    Hi Ievgen, I'm just trying to modify the value of the second field automatically after modifying the first field on the form, I added a code to the modify method of the first field but it doesn't work

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: set up value to a form control

    Hey Ameni Omrani,

    Could you please share  your code ? It's hard to say what is wrong without seeing actual code.

    Meanwhile you can check this blog post ajstudi0.blogspot.co.nz/.../microsoft-dynamics-ax-table-method.html

    section about modifiedField method.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans