Attachments in Epicor

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

1 Like

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.

3 Likes

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!

Ummm… where is that code running?…

In a custom code widget in a custom action BPM on a UBAQ.

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?

Is this a unc path? this seems to work better then using a mapped drive and going from there.

My path to the network drive and file looks something like this: “\\SERVER6\Mat Certs\C12345.pdf”

1 Like

well it was a shot in the dark lol that got me when trying to do things like that.

Indie Film Movie GIF by Raven Banner Entertainment

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;

1 Like

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!

That’ll print on the server lol.

So… What’s the code to just print a file from the server on my local PCs default printer? :slight_smile:

I think there is a solution in here but it looks very similar to my code:
Automatically Printing Attachments - Code Review / Sharing - Epicor User Help Forum (epiusers.help)

Classic or Kinetic?

Does the server have access to the UNC Path? Does the client?

Classic:
If the server has access, I would pull the data down from the server in a
function, then print from the client.

Kinetic:
Idea still
Loading Downloading GIF

1 Like

Referencing these two posts:

And a LOT of failure, I have successfully taken over the SysTask and ReportMonitor business
objects.

I can now send arbitrary PDFs to them, and kinetic and the edge agent will happily preview or print them, automagically :slight_smile:

Still needs a bit of work, but it’s sweet.

I don’t know what other types can be printed, anyone know?

What’s the goal? I’m not following the use case (though neat)

I’m not sure :rofl:

Printing all (part) file attachments from a button in Kinetic is what Nate wants.

Is there anything already?

Works in classic too, yay !