In Dynamics AX 2009, we had a requirement to attach document with Purchase order table using x++ code while performing few options with PO.
For that purpose, we have to use following x++ AOT objects
void attachDoc(RefTableId _refTableId, RefRecId _refRecId, selectableDataArea _refCompanyId, FileName _name)
{
DocuRef docuRef;
DocuActionArchive archive;
;
docuRef.clear();
docuRef.RefRecId = _refRecId;
docuRef.RefTableId = _refTableId;
docuRef.RefCompanyId = _refCompanyId;
docuRef.Name = _name;
docuRef.TypeId = 'File';
docuRef.insert();
archive = new DocuActionArchive();
archive.add(docuRef, _name);
}
To call this method simply write following line and your document will be attached.
this.attachDoc(tableNum(PurchTable), purchTable.RecId, purchTable.dataAreaId, filepathname);
For that purpose, we have to use following x++ AOT objects
- DocuRef table
- DocuActionArchive class
void attachDoc(RefTableId _refTableId, RefRecId _refRecId, selectableDataArea _refCompanyId, FileName _name)
{
DocuRef docuRef;
DocuActionArchive archive;
;
docuRef.clear();
docuRef.RefRecId = _refRecId;
docuRef.RefTableId = _refTableId;
docuRef.RefCompanyId = _refCompanyId;
docuRef.Name = _name;
docuRef.TypeId = 'File';
docuRef.insert();
archive = new DocuActionArchive();
archive.add(docuRef, _name);
}
To call this method simply write following line and your document will be attached.
this.attachDoc(tableNum(PurchTable), purchTable.RecId, purchTable.dataAreaId, filepathname);