Question

Attachment - Duplicate File Name

  • 12 February 2021
  • 1 reply
  • 239 views

We have started using attachments a lot more in Epicor.  My sales staff drags and drops and email from Outlook to the attachment form - which copies the attachment to a directory on my server.  The trouble comes in when an email has a subject line that has already been used for another order.  The process of dragging and dropping the file makes the file name the same as the subject.  So if customer A sends us an email with a subject of Order Request it creates the file on the server.  Then a week later customer B sends us an order with the subject of Order Request it overwrites the file on the server without warning.  Now I have the email from customer B showing on both customer A and customer B’s orders.  Is there a way - either in windows or Epicor - to append the date/time to the file name when you drag and drop to save?  Or is there a way to get the server to put something (like (1)) on the new file so the file name is not the same?


1 reply

hi, we have done a customization (for folder structure  sharepoint and file system storage).

In data directive > load table “XFileRef” > InTransaction > create group “subfolder”

this is for filesystem storage code… rudimental one.

Copy, paste below code in custom code widget.

foreach(var item in ttXFileRef.Where(i=>i.RowMod == "A"))
{

string fileloc = item.XFileName;
string xfilenum = item.XFileRefNum.ToString();
string filename = System.IO.Path.GetFileName(fileloc);
string parent_Folder = System.IO.Path.GetDirectoryName(fileloc);
string child_Folder = System.IO.Path.Combine(parent_Folder, xfilenum );
System.IO.DirectoryInfo directory = System.IO.Directory.CreateDirectory(child_Folder); 

string destFile = System.IO.Path.Combine(child_Folder, filename);
System.IO.File.Copy(fileloc, destFile, true);

item.XFileName = destFile;

}

 

code

 

Reply