Hi all ,
I have to attach a file for particular SalesOrder.That file should be reflected in purchase order too.This should be done through one job.
Help me !
Thanks in Advance
Hi all ,
I have to attach a file for particular SalesOrder.That file should be reflected in purchase order too.This should be done through one job.
Help me !
Thanks in Advance
Does the sales order and purchase order are related? Please provide more details.
hello kranthi ,
salesorder related with purchase order via salesId.In purchtable it isi ntercompanyorginalsalesid.
The doucment attachment form is docuview.
Use DocuRef table and Docu::insertFile(). You can see an example in TrvReceiptsHelper.attachFileToEmployee().
Hello martin,
Thanks for ur reply.
static void Attachment_doc(Args _args)
{
Dialog dialog;
DialogGroup dialogGroup;
DialogBox dialogBox;
DialogField SalesID;
DialogField Filenameopen;
DialogField typeid;
FileIOPermission permission;
DocuRef docuRef,docuRef1;
DocuActionArchive docuActionArchive,docuActionArchive1;
SalesTable _salesTable;
PurchTable _purchTable;
DocuAction docuActionLocal;
Args args;
str _name;
dialog = new Dialog();
SalesID = dialog.addField(extendedTypeStr(SalesId));
filenameopen=dialog.addField(extendedTypeStr(FilenameOpen));
TypeId = dialog.addField(extendedTypeStr(DocuTypeId));
dialog.run();
if (dialog.closedOk())
{
try
{
ttsBegin;
//find the selected Sales record
_salesTable = SalesTable::find(SalesId.value());
_purchTable = PurchTable::findRecId(_salesTable.InterCompanyOriginalSalesId == SalesID.value());
// select PurchId from _purchTable where _purchTable.InterCompanyOriginalSalesId == SalesID.value();
//Create DocuRef table record and set required values
docuRef.initValue();
docuRef1.initValue();
//TableId, for which the document should be attached.
docuRef.RefTableId = _salesTable.TableId;
docuRef1.RefTableId = _purchTable.TableId;
//RecId, for which the document should be attached.
docuRef.RefRecId = _salesTable.RecId;
docuRef1.RefRecId = _purchTable.RecId;
docuRef.RefCompanyId = _salesTable.dataAreaId; //CompanyId, for which the document should be attached.
docuRef1.RefCompanyId = _purchTable.dataAreaId;
docuRef.TypeId = Typeid.value(); // The type of document
docuRef1.TypeId = Typeid.value();
docuRef.insert();
docuRef1.insert();
//To stores the file to document archive
docuRef.selectForUpdate(true);
docuActionArchive = new DocuActionArchive();
docuActionArchive.setDocuType(docuRef.TypeId);
docuActionArchive.add(docuRef, Filenameopen.value());
docuRef1.selectForUpdate(true);
docuActionArchive1 = new DocuActionArchive();
docuActionArchive1.setDocuType(docuRef1.TypeId);
docuActionArchive1.add(docuRef, Filenameopen.value());
ttscommit;
info(“Document successfully attached”);
}
catch
{
error(“Document attachment failed”);
}
//creating action class object based on document type
docuRef= DocuRef::findRecId(DocuRef.RecId);
docuActionLocal=DocuAction::newDocuType(docuRef.docuType());
//create args object
args=new Args();
args.record(docuRef);
args.record(docuRef1);
args.parmEnumType(enumNum(DocuCode));
args.parmEnum(DocuCode::Open);
//run the action class to open the document
// docuActionLocal = new DocuAction();
// docuActionLocal.findDocuTable(docuRef.RefTableId);
// docuActionLocal.run(args);
}
}
This is my job.It works for sales order attchment.But the attachment is not reflected in purchase order
You can use \Classes\Docu\copyDocument
You don’t have to reinvent the wheel
You can use existing API’s as Martin and I suggested.
Thanks martin and kranthi