≡ Menu

Document Attachment through X++ code Dynamics Ax 2012 R3.

During development there is requirement to import attached form physical location and shown in attachment to Dynamics AX.


I found X++ snippet from following links





In Dynamics Ax 2012 there is one table and one class which are responsible for holding and load document from file location and copied it to specific location.


  • DocuRef table
  • DocuActionArchive class



But there is one more thing, here we required two more reference, one is record recId and table where this rec Id exists. For example if we have to attached document with customer than we required the Recid of customer and table number for customer table.


Following code is attaching file form c drive and attached to Customer with account num “US-004” In demo data


static void Job3(Args _args)


DocuRef docuRef;

DocuActionArchive archive;

CustTable _custtable;

str _name;




select RecId from _custtable where _custtable.AccountNum =="us-004";


if (_custtable!=null)




docuRef.RefRecId = _custtable.RecId;

docuRef.RefTableId = tableNum("custtable");

docuRef.RefCompanyId = curext();

docuRef.Name = _name;

docuRef.TypeId = 'File';


archive = new DocuActionArchive();

archive.add(docuRef, _name);







When I run this X++ test job I found document is attached as follow



{ 0 comments… add one }

Leave a Comment