Good afternoon,
I am researching Epicor attachments. For this post we are not going to consider ECM, Epicor’s scanning solution. We are only interested in the native attachment functionality.
I have a part master method with some attachments at the part, assembly, operation and materials levels. Can I print all these at once for a given job? I picture this as a button in Job Entry that says print all attachments. From there It would iterate through the XFileRef and XFileAttch tables to pull out the attachments that are linked to the part (at some level), then print each attachment all at once, so we don’t have to open each one and click print.
There are two tricky parts for me. 1: Identifying the right attachments to print from those tables. And 2: Physically printing the attachments to a printer. What code do I use to trigger a file attachment to print? How can I build a BAQ to return all the attachments for a part? There could be attachments at the part level, assembly level, operation level and/or material level. Those tables need to be filtered by the RelatedToFile field which defines the table the attachment is linked to. Since there are many levels to this, it seems very tricky.
In the future this same feature will be requested through the job entry form. So a job is created from a part master method, and pulls in all the attachments from the part master. Then you can print the attachments from the part, or from the job.
Remember, this is all without ECM. For now, I am only interested in the native attachment processes in Epicor.
Thank you for your time!
Nate
If this is your first stab at attachments, there is a setting in the config file duplicate attachments with the same name (DuplicateAttachmentMode) depending on how it is set it will add a date stamp to the filename or prompt the user to overwrite the file. If your working with similar file names, may not want the prompt option.
Not sure how this works in the Kinetic UI. Something to test.
I can’t seem to find a way to print a specific attachment from Epicor. Obviously, I can click on it and print it, but this doesn’t seem to generate any trace that I can see in the log. I was hoping there was a print method, or something I could call from a BPM. Chat GPT sent me down a rabbit hole trying to use Process.Start.
I am starting with a UBAQ that pulls all the attachments into a single list. There is a simple flag bit field in the UBAQ to help the custom code step through each row. Here is the code I have tried that doesn’t seem to output anything. It does properly update the bit fields to true once it is done.
var xRow = (from ttResults_Row in queryResultDataset.Results where ttResults_Row.Calculated_Flag == false select ttResults_Row).FirstOrDefault();
if (File.Exists(xRow.XFileRef_XFileName))
{
ProcessStartInfo info = new ProcessStartInfo(xRow.XFileRef_XFileName);
info.Verb = "Print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
}
xRow.Calculated_Flag = true;
Does anyone have a snippet of custom code that will print a file to the default printer?
Thanks!
Not the most elegant solution but if you take the whole process outside as a stand alone application, it could be simpler to accomplish. You could offer it s a link/button on the form with JobNum as a parameter
It looks like with this code, the file is not found. My files are on a networked folder. Normally I access them through my desktop. Do I need to enable something in Epicor to allow it to see the files on our network? The weird part is that Epicor can clearly see and open the files or print the files using the native functionality by clicking each attachment. Perhaps I just have some wrong syntax in there?
I’d be thinking the UNC path needs to be shared for ‘Everyone’ since the BAQ will execute and call the OS File.Exists command as the Appserver execution account. LocalService and those accounts won’t work with non-local paths.
I built a little SQL Function that works for all Paths that I’ve tried. You should be able to call it in the BAQ and it will execute as the SQL Server execution account (if that helps)
CREATE FUNCTION [dbo].[fn_FileExists](@path varchar(512))
RETURNS BIT
AS
BEGIN
DECLARE @result INT
EXEC master.dbo.xp_fileexist @path, @result OUTPUT
RETURN cast(@result as bit)
END;
Neat! I don’t use SQL functions, either because they are too complicated to figure out, or I am cloud DT. I will take a look at the permissions for that folder. I know they are restricted to a subset. I was hoping that the File.Exists function would use my user account and permissions. Thanks Mike!