Monday, 24 October 2016

Referencing a form control [AX7]

I am seeing this a lot more these days because of extensions in AX7. You tend to take the form run in the event and try to get a form control.

A lot of developers seem to be hard coding the control name. Not wrong but not the best way to do it. A form control name could change or be deleted. Then you wont catch this until a user runs it.

Not so good way:

formRun.design().controlName(“MyControlName”)

formRun.design().controlName(identifierStr(MyControlName));

The right way:

formRun.design().controlName(formControlStr(MyFormName, MyControlName));

This way you get your errors during compile time.

No comments: