public void docHandlingAdd(filename filename)
{
Args args = new args();
formrun FormRun;
//filenameSave filename;
Args args1 = new args();
//wfsEMSalesOrderDocumentation wfsEMSalesOrderDocumentation;
docuref docuref;
form form2;
FilenameFilter _conFilter;
filename file, docuFilename;
recid docuvaluerecid;
docuvalue docuvalue;
int hwnd;//wfs ctodd 6/21/2012
salestable salestable = salestable::find('SO-101342');
docutype docutype;
DocuActionArchive archive;
System.IO.FileInfo fileInfo;
int size;
Filename onlyFilename;
Filename curFileType;
;
if(SalesTable)
{
_conFilter = ['All FIles','*.*'];
//hWnd = this.hWnd();
//file = WinAPI::getOpenFileName(infoLog.hWnd(),_conFilter,'','Select Document Path');
file = filename;
if(file)
{
ttsbegin;
docuref.TypeId = "Test";
docuref.Name = "T&L-TDD-V1.2";
docuref.Notes = docuRef.Notes;
docuRef.Restriction = DocuRestriction::External;
docuref.RefCompanyId = SalesTable.dataAreaId;
//docuref.WfsExportType = wfsexporttype::CommercialInv;
docuref.RefTableId = tablenum(SalesTable);
docuref.RefRecId = SalesTable.RecId;
docuref.insert();
docuvalue.initValue();
docuvalue.insert();
docuref.ValueRecId = docuvalue.RecId;
docuref.update();
docuvaluerecid = docuvalue.RecId;
//select forupdate docuvalue where docuvalue.recid == docuvaluerecid;
//docuvalue = docuvalue::writeDocuValue(docuref,file);
/*fileInfo = new System.IO.FileInfo(file);
size = fileInfo.get_Length();
info(strfmt("%1",size));*/
archive = new DocuActionArchive();
archive.add(docuRef, file);
/*
docutype = docutype::find(docuref.TypeId);
numSeq = NumberSeq::newGetNum(DocuParameters::numRefDocuNumber(),true);
[onlyFilename,curFileType] = Docu::splitFilename(file);
if(docuType.filePlace == DocuFilePlace::Archive)
{
docuFilename = docuRef.path()
+ smmDocuments::getNonExistingFileName(numSeq,docuRef.path(),curFileType)
+ '.'
+ curFileType; //new Filename
//uses curFileType
WinAPI::copyFile(filename, docuFilename);
}
else
{
docuFilename = filename;
}
this.insertDocuValue(docuRef,docuFilename);*/
ttscommit;
//docuFilename = docutype.ArchivePath + "\\";
//WinAPI::copyFile(file, docuFilename);
}
}
}
Using the above method
--------------------------
filename file = "C:\\Users\\hemamalinib\\Downloads\\Tips_for_Creating_Services_in_Microsoft_Dynamics_AX_2009.pdf";
KT_DocuHandlingService AIF_DOCHandCustomService_add = new KT_DocuHandlingService();
//adding new file/document to record
AIF_DOCHandCustomService_add.docHandlingAdd(file);