How to add a document into AX programmically (Document handling)

As a matter of fact it's pretty easy. Following lines allow you do this.
void saveIntoDocuRefTable()
        DocuValue docuValue;
        DocuRef docuRef;
        Container cFile;

        BinData binData;
        DocuTypeId _docuTypeId = ...;

        binData = new BinData();

        cFile = Docu::splitFileName(fileName);
        docuValue.fileName = conpeek(cFile,1);
        docuValue.path = conpeek(cFile,3);
        docuValue.fileType = conpeek(cFile,2);
        docuValue.File = binData.getData();

        docuRef.ValueRecId = docuValue.recId;
        docuRef.RefCompanyId = CurExt();
        docuRef.RefTableId = tableNum(....);
        docuRef.RefRecId = .....;
        docuRef.TypeId = _docuTypeId;
        docuRef.Name = fileName;
        docuRef.Notes = ....;


1 comment:

akash said...

Hi Ruslan ,

i have created a form where there are different categories for the customer i handle the documents for each category seprately and i can view them as well but when i want to look all the documents of the customer for all catogeries i am unable to retrieve the documents of the customer can u please tell me how to attact the customer id to the document view form so that i can pull up all the documents of the customer from all catogeries...
thanks in advance