It took me a while to get to the final solution, but I got there!
The business reason behind this solution is wanting to automatically attach certificates that get attached to the Receipt Line to the Part Lot record. If you have requirements that you need to track certifications for your parts, either for internal and/or customer need, this takes the attachments added at receipt and attaches them to the Part Lot in the background. By doing this, it will be easier for users to get to the documentation by just going through Lot Tracker. Otherwise, they would have to go to Lot Tracker, find the receipt record, and then go to the receipt to get the document. This will also facilitate the ability to create a customization to gather all documentation for a Job by looping through the parts, seeing if they are lot tracked, and then checking the PartLot for the document. That will be my next step, building an APR that grabs all of the documents and prints/emails them out.
The first step is to create Document Types for whatever repository you are using with Document Type Maintenance. I am using ECM, but this should work for anything. I created a document type with a Certs ID. I also flagged it as Reserved for Specific Tables and required for Receipt and Shipment.
Next is to create the specific table control using Document Type Control Maintenance. Here you select the Table and Document Type. Also select Expose in Tree (it does not work in the web, but I am hoping Epicor fixes that). You want to do this for the PartLot and RcvDtl tables.
Next you want to select the Metadata to associate with the Document Type. Here is what I selected. This helps with searching for documents where they are stored (if it supports the transfer of the metadata).
Now that the document controls are set up, you can start creating the customization. First is a Standard Data Directive on XFileAttach. You want to trigger your customization when the document is successfully attached in the DB. Interesting thing to note here, documents are processed one at a time. Even if you add multiple attachments at once, each document goes through by itself and not in a group. Here is the workflow and variables.
- Start with a Condition checking that there is an added row in the table.
- Next are two Set Variable to take the ForeignSysRowID and XFileRefNum so you can pass them to a Function.
- The first Invoke Function is to get the Document Type. I left this as a separate function as this can be used for other instances where you need to duplicate an attachment.
- The second Function is to attach the document to the other table.
Now I will detail the Functions.
GetDocType is just like it sounds, it gets the Document Type because it is not available in the XFileAttach table. It is a Custom Code block with the following in it.
string xDocType = Db.XFileRef.Where(x => x.XFileRefNum == refNum)
.Select(x => x.DocTypeID).FirstOrDefault();
if (xDocType != null)
{
docType = xDocType;
}
string xFileName = Db.XFileRef.Where(x => x.XFileRefNum == refNum)
.Select(x => x.XFileName).FirstOrDefault();
if (xFileName != null)
{
fileName = xFileName;
}
refNum2 = refNum;
The other Function is AttachCertsPartLot, that does as it sounds. There are some BO calls to get data and then uses the data to call the PartLot Attach method and Update method to save it.
- First is a BO call of RcvDtlSearch.GetBySysRowID where you use the ForeignSysRowID from earlier to get the row for the PartNum and LotNum.
- Next is a condition to check that the LotNum field is populated and that the DocType is Certs.
- Another BO call of LotSelectUpdate.GetNewPartLotAttach to get the LotSelectUpdateTableset with the PartNum and LotNum.
- The next 3 blocks set fields in the tableset. First is RowMod = A, next is to set the FileName, and last is the DocTypeID.
- Now that you have added the data to the tableset, you can run the Update method to finish it off.
Done. Attachment now lives in both tables. Let me know if you have any questions.
Here are some posts that I did in trying to get to my final solution. My issue was that we own ECM but do not own either of the Integration Modules, so I could not do it in ECM like I originally wanted to. I did figure out how to reach the ECM API, but thought it would be too much work trying to build the integration myself.