AxdBase.create Method [AX 2012]
Creates the document in the XML string as a transaction in the database tables, and then returns the entity key of the created transaction.
Syntax
public AifEntityKey create(
AifDocumentXml _xml,
AifEndpointActionPolicyInfo _actionPolicyInfo,
AifConstraintList _constraintList)
Run On
Server
Parameters
- _xml
Type: AifDocumentXml Extended Data Type
An XML string that contains the data (transaction) to persist to the database.
- _actionPolicyInfo
Type: AifEndpointActionPolicyInfo Class
An instance of the AifEndpointActionPolicyInfo Class. Use it to specify the value mapping to perform. This class can be empty if no value mapping is to occur.
- _constraintList
Type: AifConstraintList Class
A list that contains the constraints that are identified for the document.
The _constraintList parameter must be an instantiated, empty AifConstraintList Class. It is populated when the create method is run.
Return Value
Type: AifEntityKey Class
The entity key that defines the created transaction.
Remarks
The create method is implemented on the AxdBase Class.
If a document does not provide the corresponding action type (ReceiveDocument), the create method on the class for that document type must be overridden. If the create method is called, it throws an error. For example, the implementation of the AxdPurchaseRequisition.create method is as follows.
public AifEntityKey create(
AifDocumentXml _xml,
AifEndpointActionPolicyInfo _actionPolicyInfo,
AifConstraintList _constraintList)
{
throw error(strfmt("@SYS94924", this.getName(), 'create'));
}
Examples
The following example shows how to create a sales order from the SalesOrderDocument.xml file.
XMLDocument xmlDoc = new XMLDocument();
AifDocumentXml xml;
AxdSalesOrder SalesOrder;
AifEndpointActionPolicyInfo actionPolicyInfo = new
AifEndpointActionPolicyInfo();
// Value mapping is not used here, but the
// AifEndpointActionPolicyInfo class must be instantiated.
AifConstraintList constraintList = new AifConstraintList();
// The object will be populated when the
// AxdBase.create method is run.
AifEntityKey entityKey;
FileIOPermission fileIOPermission = new FileIOPermission(
'C:\\SalesOrderDocument.xml',
'r');
fileIOPermission.assert();
if (xmlDoc.load('C:\\SalesOrderDocument.xml'))
{
xml = xmlDoc.xml();
SalesOrder = AxdBase::newClassId(Classnum(AxdSalesOrder));
entityKey = SalesOrder.create(
xml, actionPolicyInfo,
constraintList);
}