Skip to main content

Posts

Showing posts with the label Date Value

Set a Date Value to a Date Filed in AX 2009 with X++

I was faced with a requirement that I needed to set a date value to a custom date Filed in AX 2009 with X++, with the Purch Order Creation Date. I knew that the following could work: ... FormControl control; ; control = element.design().controlName('PurchTable_OrderDate')); control.Text = DateTimeUtil::ToStr(purchTable_ds.Object(fieldnum(PurchTable, CretationDateTime); ... However, I wanted to create a solution that would not be so dependant on the Form object as this can bring headaches when upgrading. Therefore, I decided to do it at the data source level as follow: purchTable_ds.object(fieldnum(PurchTable, OrderDate)).setValue(DateTimeUtil::date(purchTable.createdDateTime)); The above code is far more efficient and it needs to be set either in the Data Source (PurchTable) of the PurchTable form Init() or Active() method.