Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

[AX 2012] Modify form field value in X++

Posted on by 1,085

Hi, 

how do i modify the value of a form field in X++?

 

I  found SetValue() method but doesnt seem to work out. 

Is there a .value property which can be set in order to change the value of a field at runtime?

 

Thank you in advance 

regards

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [AX 2012] Modify form field value in X++

    You can modify the value in the form control by using the .text() method. (The control have to be the AutoDeclaration property set to Yes).

    or you can try

    Table.field = XX;

    element.redraw();     //to refresh the form

  • Ian_Boothby Profile Picture
    Ian_Boothby on at
    RE: [AX 2012] Modify form field value in X++

    FormStringControl strResult;

    strResult = element.design().control(element.controlId("strResult"));

    strResult.text("this is what it should say");

  • RE: [AX 2012] Modify form field value in X++

    In this case the usual way is to set form control values in the super() method of the form, after the super() sentence.

    Note that this shouldn't be appliable to controls related to datasource data.

  • Anton Venter Profile Picture
    Anton Venter 18,474 Super User 2024 Season 2 on at
    RE: [AX 2012] Modify form field value in X++

    Can you be more specific? What do you want to do? What is the problem?

  • Codehunter Profile Picture
    Codehunter 10,270 on at
    RE: [AX 2012] Modify form field value in X++

    what method I need to set value while opening form

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [AX 2012] Modify form field value in X++

    hey,

    try to save it direkt to the table.

    eg.

    inventTable.field =  value

    inventTable_ds.refresh()

  • Re: [AX 2012] Modify form field value in X++

    Ok, the easiest way to do so is:

    1.- Set the Autodeclaration property of the control to Yes.

    2.- Now, to set the value in X++, put the name of the control, and the proper method (varies based on the basic data type of the control).

    Examples:

    StringEdit.text("Hello");

       RealEdit.realValue(4.5);

       IntEdit.value(5);

       ComboBox.selection(2);

  • vv1984 Profile Picture
    vv1984 1,085 on at
    Re: [AX 2012] Modify form field value in X++

    Form controls. More exactly i'm trying to set a text field's value.

  • Re: [AX 2012] Modify form field value in X++

    Are you speaking about dialog controls, or form controls?

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,246 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,041 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans