asp.net - How do I upload a file to an Acumatica Screen through HTTP virtual path? -
how upload file acumatica screen through http virtual path? example, upload mysite.com/files/abc.pdf sales orders screen.
below code snippet achieve goal.it reading file http url , attaching 1 of existing case.
//graph file management px.sm.uploadfilemaintenance filegraph = pxgraph.createinstance<px.sm.uploadfilemaintenance>(); //since need file http url - below sample webrequest request = webrequest.create("http://www.pdf995.com/samples/pdf.pdf"); using (system.io.stream datastream = request.getresponse().getresponsestream()) { using (system.io.memorystream mstream = new system.io.memorystream()) { datastream.copyto(mstream); byte[] data = mstream.toarray(); //create file info, may check different overloads per need px.sm.fileinfo fileinfo = new px.sm.fileinfo("case.pdf", null, data); if (filegraph.savefile(fileinfo)) { if (fileinfo.uid.hasvalue) { // attach file case screen - example crcasemaint graphcase = pxgraph.createinstance<crcasemaint>(); //locate existing case graphcase.case.current = graphcase.case.search<crcase.casecd>("<case want attach file>"); //to attach file pxnoteattribute.setfilenotes(graphcase.case.cache, graphcase.case.current, fileinfo.uid.value); //to attach note pxnoteattribute.setnote(graphcase.case.cache, graphcase.case.current, "<note wish specify>"); //save case graphcase.save.press(); } } } }
Comments
Post a Comment