SBX - Search With Button

SBX - Forum Post Title

Access form control in edit method of a form extension class

Microsoft Dynamics AX Forum

Priyan asked a question on 13 Jun 2018 1:18 PM

Question Status

Verified

Hi,

I have added two form controls to a form extension; one drop-down(Field01) and another a text box(Field02). Based on the selection made in drop down the text box gets populated with some description. Now, all this is done in an edit() method in a class (for the form extension). Field02 is not associated to any table, it is just a display of the description. How can I access the text box form control and set a value for it?

Note:- I did not create the edit() in table extension class because of the need to access form control Field02.

e.g. Form extension = PurchTable.Extension

Class Extension:-

[ExtensionOf(formStr(PurchTable))]
final class PurchTable_Extension

{

public static edit Description editField01(PurchTable _this, boolean _set = false, Str60 _recid = "0")

{

_this.Field01 = str2int64(_recid);

//Some more code

// This is where I am trying to access Field02 to set some value to it.

Field02.text("");

}

}

Reply
Martin Dráb responded on 14 Jun 2018 12:26 AM
Verified Answer

If Field02 is bound to a field on PurchTable, you can ignore the control and simply look at the field.

If it's an unbound control, a solution may be getting a datasource from _this and than a form reference from the form datasource. Then you'll access the control on the form.

Reply
Priyan responded on 14 Jun 2018 2:10 PM

Field02 is unbound. I got the FormRun object from _this.datasource(). Thanks!

Reply
Martin Dráb responded on 14 Jun 2018 12:26 AM
Verified Answer

If Field02 is bound to a field on PurchTable, you can ignore the control and simply look at the field.

If it's an unbound control, a solution may be getting a datasource from _this and than a form reference from the form datasource. Then you'll access the control on the form.

Reply

SBX - Two Col Forum

SBX - Migrated JS