How to: Create a New Record When a Form Opens
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
To create a new record every time that the user opens a form:
Call the create method on the form data source.
Set the InsertAtEnd property on the form data source to No.
Set the StartPosition property on the form data source (to First or Last).
Example
The following example is from the run method in the PurchCreateOrder form. purchTable_ds is the variable for the PurchTable data source on the form.
void run()
{
purchTable_ds.create();
element.modifyForm();
super();
purchTable_ds.lookUpOrderAccount();
if (!purchTableType)
{
element.close();
throw Exception::Error;
}
}
See also
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.