Axapta: Edit form field values

10,389

If the field is bound to a datasource, you have to modify the value in the datasource. If the field is bound to a variable, then modify the value of the variable itself. It is the easy an smart way to do it.

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). This is a setter-getter (parameter) type method used in AX. If no parameter is passed, it is user as getter (read). If you pass a value, this is a setter (write).

Hope this helps.

Share:
10,389
Brad
Author by

Brad

What I lack in ability, I make up for in effort.

Updated on June 04, 2022

Comments

  • Brad
    Brad almost 2 years

    Using a 'clicked' override on a button, I'd like to modify values in an Axapta form.

    I'm able to get data from the form field using:
    str strOld = Form_FieldName.valueStr();

    I'm able to prepend text to the field using:
    Form_FieldName.pasteText(strNew);

    I can't seem to find a .clear method or .value= method. I'd like to replace the entire value in the field with new information.

    Thanks

  • Brad
    Brad over 14 years
    Thanks for the help. When I use the .text(myValue) method, no exceptions are thrown, but nothing happens on the form either. The field is databound. Do you mind posting a bit of example code for modifying a value in the datasource? Thanks
  • j.a.estevan
    j.a.estevan over 14 years
    It whould be usefull if you post your own code with the exact problem you have. Datasource will be a table. You can make: Table.field = XX; element.redraw() //to refresh the form; Be carefull that this will modify the value in the database if you change the record (as usual in the standard)
  • Brad
    Brad over 14 years
    That worked perfectly. I'm just getting started in x++ after years of .NET. It's been a bit of a painful transition. I really appreciate your help.
  • j.a.estevan
    j.a.estevan over 14 years
    Good luck with the learning. Syntax and philosophy is the same, just we have to fight with those tons of classes ;)