1 Apr 2017

Attach files through X++ in AX 2012


Public void attachments()
{
    Filename            fileName  = @'D:\AX\Files.csv';
    DocuRef             docuRef,d
ocuRefLoc;
    DocuType            docuType;    
    HcmWorker           hcmWorker =      HcmWorker::findByPersonnelNumber('123456');
    DocuActionArchive   docuActionArchive;
    ;
    select docutype where docutype.ActionClassId == assNum(DocuActionArchive)                                                        &&  DocuType.TypeId == 'file' ;
      docuRef.RefRecId       = hcmWorker.RecId;
    docuRef.RefTableId     = hcmWorker.TableId;
    docuRef.RefCompanyId   = 'DAT';
    docuRef.TypeId         = docutype.TypeId;
    docuRef.insert();
    ttsBegin;
    select forupdate docuRefLoc where docuRefLoc.RecId ==  docuRef.RecId;
    docuActionArchive       = DocuAction::newDocuRef(docuRefLoc);
    docuActionArchive.add(docuRefLoc, fileName);
    ttsCommit;
}

No comments:

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...