A blog (primarily about Dynamics AX/D365) covering topics like X++, AX for Retail, D365 Commerce, Trade and Logistics, retail concepts, warehousing, etc. Something for everyone. Grab bag blog for whatever I think would help out people in the Dynamics AX/Commerce/Retail community. The opinions expressed on this site are my own and do not necessarily represent the views of my company
Wednesday, December 2, 2009
Making independent Form Controls Mandatory or changing labels in code: AX 2009
Here is a quick code snippet to access some features of AX form controls that are not too obvious to get to.
In order to have total access to change whatever you want to AX form controls that are either tied to Datasources or just floating on their own to a form (like a filter), you have to grab the control from the form and set it equal to a form control variable.
In the example below, it is FormStringControl. This is helpful for making something like a combo box that is standalone in the form (like a filter).
FormStringControl formControl;
;
formControl = element.design().controlName('NameOfField');
formControl.label("New Dynamic Runtime label");
formControl.mandatory(true);
You can also use control specific types like FormComboBoxControl but combo boxes are strings and the strings give you more options. Just remember that making a base enum could be a problem as default values for some of these are 0 which is a valid value. Only enums with a starting value of 1 would benefit from something like this as 0 would be an invalid value.
Subscribe to:
Post Comments (Atom)
Thanks a lot.
ReplyDelete