Has anyone added an attachment to a document via a customization script? I know that the attachment file must first be “registered” in Epicor before being attached to the desired Epicor document. Via a trace, I learned that the required business object library for registering the attachment file is Ice.Contracts.BO.Attachment.DLL. Through trial and error, I discovered that the affiliated adapter object library is Ice.Lib.EpiClientLib.DLL, which contains the attachment logic. In the customization, I can create the adapter object and connect to the BO. But it won’t recognize any of the BO methods. I need the FileExists method that checks to see if the attachment file already is registered with Epicor (exists in Ice.XFileAttch) and the UploadFile method to write the information to Ice.XFileAttch if it doesn’t exist. The writing to the pseudo attachment tables in a document adapter dataset (InvcHeadAttch for the ARInvoice adapter for example) to link an existing Ice.XFileAttch reference in the various document entry and tracker UIs work fine.
The reason for this is we are trying to automate attaching UPS delivery receipts to the affiliated ShipHead, OrderHed and InvcHead records to help dispute invalid chargebacks by customers who claim merchandise wasn’t received in time or at all.
We do this, but via the “…Attch” parts of the individual adapters.
So, for example, in one I have to hand,
Erp.Adapters.QuoteAdapter qAdapter = new Erp.Adapters.QuoteAdapter(oTrans);
qAdapter.BOConnect();
if (qAdapter.GetByID(quoteno))
{
if (qAdapter.GetNewQuoteHedAttch(quoteno))
{
Erp.BO.QuoteDataSet dsQuote = qAdapter.QuoteData;
foreach (DataRow newrow in dsQuote.QuoteHedAttch.Rows)
{
if (newrow["RowMod"].ToString() == "A")
{
newrow["FileName"] = fto;
newrow["DrawDesc"] = System.IO.Path.GetFileName(fto);
break;
}
}
qAdapter.Update();
}
else
{
System.IO.File.Delete(fto);
MessageBox.Show("Failed to attach." + System.Environment.NewLine + fto);
}
}
Added:
I just noticed you said this part was working fine. The only other thing we do is to get the Epicor attachment file location from the company configuration data and use standard System code to move the file there before calling the above. We have never used any other BO than the ones in the individual adapters. In actual fact, it doesn’t even seem to matter if the file is in the normal location as long as it’s accessible to Epicor and the relevant users - we do some very particular files in a different location altogether.
When I tried with just the adapter code, I couldn’t get it to recognize the DocumentType. This particular document we want to not be a link and also to save the docs in a different path. It kept attaching based on the default settings in Company Maintenance. I have been making various changes to the code along the way and may have it behaving differently than when I first tried to attach. I will try again to just use the adapter code, and see what happens and post here. Thanks.
Hi Guys, I need one help. I am new to epicor. whether this can be done through BPM?
Whenever the PO is created either using Buyer Workbench or Purchase Oder Entry these 2 document (GTC & STC) should be automatically attached.
I have read through your conversations and tried in customization code it is working fine. but it will not affect both the screens. So Now I want the same concept should work through BPM. please share some sample BPM code for this. Any help is highly appreciated. Thanks in advance.
if that is not possible through BPM. I want to know the reason behind this.
If you were able to achieve the action in customization C# code, you should be able to duplicate it in a Pre-Processing Method Directive for PO.Update with a custom code object. The trigger conditions would be if ttPOHeader has an added row and the CallContextClient AssemblyName equals the Buyer Workbench or PO Entry DLL names.