Attachments in Epicor

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 !

When we build up a part master we want to include the various drawings and specs for each step to avoid having to produce them physically. We might have a specific drawing for 5 of our 10 operations, along with a few sheets of overall blueprints. Along with material certifications. They want to be able to easily print all the attachments for a job if needed. I think the need will be high at first while we transition to a more paperless system. As it is now, you have to click on each attachment (first find the attachment if there are many assemblies and operations), then click print for each attachment.

The overall goal is to have an easy way to manage attachments in Epicor. And as I said in the intro, for now this is without ECM. We want to be able to quickly see a list of all the attachments for a part. Have those attachments get pulled into new jobs created for that part, quickly see a list of all the attachments for a job, assembly, or operation. Quickly print all the attachments for a job, assembly operation or part master. Quickly open all the attachments for a job, assembly, operation, or part master.

I am surprised it is so hard to print a file programmatically from Epicor.

Predict Schitts Creek GIF by CBC

1 Like

This was me a while back, I’m still there, but at least there have been improvements
and workarounds.

Thank goodness for the people on this forum.

2 Likes

You don’t give yourself enough credit. You are rocking in the free world man.

2 Likes

Where do you think I would be without you guys?

Here, is where:

g help GIF

All you people talking to me about imposter syndrome, I promise you, it goes both ways.

1 Like

When I run this code, I can see that the user is “EPICORDT\12345”. Obviously, this isn’t a user at the domain level. Can I add folder level permissions in windows to allow this user account to use File.Exists?

var xRow = (from ttResults_Row in queryResultDataset.Results where ttResults_Row.Calculated_Flag == false select ttResults_Row).FirstOrDefault();
var windowsIdentity = WindowsIdentity.GetCurrent();
if (windowsIdentity != null)
{
    myMessage += "User: " + windowsIdentity.Name + Environment.NewLine;
}

myMessage = myMessage + Environment.NewLine + "Looking for: " + xRow.XFileRef_XFileName.ToString();
    

  
  if (File.Exists(xRow.XFileRef_XFileName.ToString()))
  {
    //Start a process to print
    Process p = new Process();
    p.StartInfo = new ProcessStartInfo()
    {
      CreateNoWindow = false,
      Verb = "Print",
      FileName = xRow.XFileRef_XFileName.ToString()
    };
    p.Start();
    myMessage = myMessage + Environment.NewLine + "Printing: " + xRow.XFileRef_XFileName.ToString();
  }
  
  else
  {
    myMessage = myMessage + Environment.NewLine + "File not Found: " + xRow.XFileRef_XFileName.ToString();
  }

xRow.Calculated_Flag = true;

Note: I also updated the network folder and files to include a read/open permission for the “Everyone” user. Even after saving and restarting, the code above still returns file not found.

There is a nice ‘Industry Extension’ that Epicor offers that Dot Net IT did back in the day that looks to be still available on EpicWeb called Job Traveller Attachment Printing.

It’s pretty cheap, a few thousand I think, and basically how it works is when you are in the Job Traveler Print screen there are extra toolbar buttons for printing the Traveler and include any attachments.

Not sure if this has been extended to the Kinetic UI yet… but it’s a nice quick and easy extension (if you can get your CAM to be able to find it in their catalog)

Epicor ERP_Extended Solutions_Job Traveller Attachments_Documentation_Job-Traveller-Attachments-Extended-Solutions-ES0104.pdf (247.7 KB)

1 Like

I wouldn’t exactly call that cheap if that’s all it does :person_shrugging:

I appreciate that! I am looking for a native approach. it seems to me all the parts are right here in front of me if I can just get them sorted out.

Does this work in classic and kinetic?
Do a trace when you open one and see if it’s just launching the link.

If it’s just launching the link, then the server isn’t accessing anything.

Classic only so far. I found this in the trace that looks promising:

<tracePacket>
  <businessObject>Ice.Proxy.BO.DOCAssocImpl</businessObject>
  <methodName>GetRows</methodName>
  <appServerUri>https://test.epicorsaas.com/test/</appServerUri>
  <returnType>Ice.BO.DOCAssocDataSet</returnType>
  <localTime>6/13/2023 13:42:16:6447028 PM</localTime>
  <threadID>1</threadID>
  <correlationId>cd68fedd-d35c-4d02-a888-33b3146e6b16</correlationId>
  <executionTime total="91" roundTrip="82" channel="0" bpm="0" bpmDataForm="0" other="9" />
  <retries>0</retries>
  <parameters>
    <parameter name="whereClauseDocAssoc" type="System.String"><![CDATA[]]></parameter>
    <parameter name="pageSize" type="System.Int32"><![CDATA[0]]></parameter>
    <parameter name="absolutePage" type="System.Int32"><![CDATA[0]]></parameter>
  </parameters>
  <returnValues>
    <returnParameter name="" type="Ice.BO.DOCAssocDataSet">
      <DOCAssocDataSet xmlns="http://www.epicor.com/Ice/300/BO/DOCAssoc/DOCAssoc">
        <DocAssoc>
          <Company></Company>
          <DocExtension>doc</DocExtension>
          <Description>Office 97 Word Document</Description>
          <ViewCommand>\\jet2\Epic50\vantage\av\avwin\avwin.exe "&amp;1"</ViewCommand>
          <PrintCommand>\\jet2\Epic50\vantage\av\avwin\avwin.exe -p "&amp;1"</PrintCommand>
          <DefaultPath></DefaultPath>
          <SysRevID>13111395</SysRevID>
          <SysRowID>fdb2ac8e-1bc6-3585-e811-4e0d8bb282d0</SysRowID>
          <AllCompanies>true</AllCompanies>
          <BitFlag>0</BitFlag>
          <RowMod></RowMod>
        </DocAssoc>
        <DocAssoc>
          <Company></Company>
          <DocExtension>pdf</DocExtension>
          <Description>Adobe Acrobat Reader</Description>
          <ViewCommand>AcroRd32.exe "&amp;1"</ViewCommand>
          <PrintCommand>AcroRd32.exe /p "&amp;1"</PrintCommand>
          <DefaultPath></DefaultPath>
          <SysRevID>13111396</SysRevID>
          <SysRowID>fdb2ac8e-1bc6-3585-e811-4e0d8fb282d0</SysRowID>
          <AllCompanies>true</AllCompanies>
          <BitFlag>0</BitFlag>
          <RowMod></RowMod>
        </DocAssoc>
        <DocAssoc>
          <Company></Company>
          <DocExtension>prn</DocExtension>
          <Description>HP Printer (.prn) Files</Description>
          <ViewCommand>\\jet2\Epic50\vantage\av\avwin\avwin.exe "&amp;1"</ViewCommand>
          <PrintCommand>\\jet2\Epic50\vantage\av\avwin\avwin.exe -p "&amp;1"</PrintCommand>
          <DefaultPath></DefaultPath>
          <SysRevID>13111397</SysRevID>
          <SysRowID>fdb2ac8e-1bc6-3585-e811-4e0d8cb282d0</SysRowID>
          <AllCompanies>true</AllCompanies>
          <BitFlag>0</BitFlag>
          <RowMod></RowMod>
        </DocAssoc>
        <DocAssoc>
          <Company></Company>
          <DocExtension>prt</DocExtension>
          <Description>Cadkey Part (.prt) File</Description>
          <ViewCommand>\\jet2\Epic50\vantage\av\avwin\avwin.exe "&amp;1"</ViewCommand>
          <PrintCommand>\\jet2\Epic50\vantage\av\avwin\avwin.exe -p "&amp;1"</PrintCommand>
          <DefaultPath></DefaultPath>
          <SysRevID>13111398</SysRevID>
          <SysRowID>fdb2ac8e-1bc6-3585-e811-4e0d89b282d0</SysRowID>
          <AllCompanies>true</AllCompanies>
          <BitFlag>0</BitFlag>
          <RowMod></RowMod>
        </DocAssoc>
        <DocAssoc>
          <Company></Company>
          <DocExtension>SSS</DocExtension>
          <Description>SKETCHES</Description>
          <ViewCommand>AcroRd32.exe "&amp;1"</ViewCommand>
          <PrintCommand>AcroRd32.exe /mFilePrint "&amp;1"</PrintCommand>
          <DefaultPath></DefaultPath>
          <SysRevID>13111399</SysRevID>
          <SysRowID>fdb2ac8e-1bc6-3585-e811-4e0d8eb282d0</SysRowID>
          <AllCompanies>true</AllCompanies>
          <BitFlag>0</BitFlag>
          <RowMod></RowMod>
        </DocAssoc>
        <DocAssoc>
          <Company></Company>
          <DocExtension>txt</DocExtension>
          <Description>Text (.txt) Files</Description>
          <ViewCommand>NOTEPAD.EXE "&amp;1"</ViewCommand>
          <PrintCommand>NOTEPAD.EXE /p "&amp;1"</PrintCommand>
          <DefaultPath></DefaultPath>
          <SysRevID>13111400</SysRevID>
          <SysRowID>fdb2ac8e-1bc6-3585-e811-4e0d88b282d0</SysRowID>
          <AllCompanies>true</AllCompanies>
          <BitFlag>0</BitFlag>
          <RowMod></RowMod>
        </DocAssoc>
        <DocAssoc>
          <Company></Company>
          <DocExtension>VER</DocExtension>
          <Description>Detail Versions</Description>
          <ViewCommand>WRITE.EXE "&amp;1"</ViewCommand>
          <PrintCommand>WRITE.EXE /p "&amp;1"</PrintCommand>
          <DefaultPath></DefaultPath>
          <SysRevID>13111401</SysRevID>
          <SysRowID>fdb2ac8e-1bc6-3585-e811-4e0d8db282d0</SysRowID>
          <AllCompanies>true</AllCompanies>
          <BitFlag>0</BitFlag>
          <RowMod></RowMod>
        </DocAssoc>
        <DocAssoc>
          <Company></Company>
          <DocExtension>xls</DocExtension>
          <Description>Excel-97</Description>
          <ViewCommand>excel.exe "&amp;1"</ViewCommand>
          <PrintCommand>excel.exe /mFilePrint "&amp;1"</PrintCommand>
          <DefaultPath></DefaultPath>
          <SysRevID>13111402</SysRevID>
          <SysRowID>fdb2ac8e-1bc6-3585-e811-4e0d8ab282d0</SysRowID>
          <AllCompanies>true</AllCompanies>
          <BitFlag>0</BitFlag>
          <RowMod></RowMod>
        </DocAssoc>
      </DOCAssocDataSet>
    </returnParameter>
    <returnParameter name="morePages" type="System.Boolean"><![CDATA[False]]></returnParameter>
  </returnValues>
</tracePacket>

This shows that PDFs should be opened with Adobe Reader. But I couldn’t find the link I printed anywhere in the trace. Maybe I have to turn on more trace flags?
(Those old Jet2 locations aren’t valid anymore, but I don’t think that impacts the PDFs)

Open up tracing, set enable trace logging, write full ds, write response data.

open up a part, find the attachment.

apply trace logging, clear trace, open the attachment

view trace log

lets see what happens