How to track who adds/deletes an attachment in Order entry

Hello,

How would I track who adds/deletes attachments in Sales Orders?

Any help is appreciated.

Thanks,

Shawn

Are you using DocStar for your attachments? It does this for you if you are.

When I am talking about attachments, I mean something like clicking on the paper clip at the top in order entry and clicking the new attachment button.

To know who attached the document, you could use a UDtable to write the User and date time information via code in a data directive on the XFileRef table, When deleting occurs, in the DD, you can write in the same UDtable the id and date time of the activity.

Pierre

That’s correct. It can be stored in ChgLog table as well.

Add 2 User fields to XFileAttch for User ID & Date, then populate with a BPM when added

For the ChgLog way, if deleted you lose the records … Epicor does not log deletions…(should be part of a new idea ?)
If you add the ud fields, again, the deletion will not be able to get written…record no longer present.

That is why I suggested the UDtable … :wink:

Pierre

Which disappears if the database gets clobbered. That’s why I recommend something like syslog, Azure Log Analytics, or Amazon Cloud Watch where not only to keep all logs together, you can follow good monitoring DevOps practice and get notified of issues.

But Chadd is spot on that we’re trying to add the auditing capability that’s built-in to DocStar or SharePoint on top of the flat file system.

Hello @Hogardy
How do I write to a UD Table from a data directive?

I have done it in the past with a method directive but not sure how in the data directive.

Any help is appreciated.

I would think a similar way…

here is a sample of code I used:
You would have a choice of either create a new record when added or deleted, or edit the original record if deleted

if (ttTable != null)
		{
				

				foreach(var Row in (from r in ttTable where (r.RowMod == "A" || r.RowMod == "U") select r) )
				{
						//here if udtable row not exists, create new
						var UD14rows = Db.UD14.Where(x => ((x.Company == Row.Company) && ( x.Key1 == param1 ) && ( x.key2 ==  param2 )  ));
						if( UD14rows.Count() == 0 )
						{
								
								using (var txScope = IceContext.CreateDefaultTransactionScope())
								{
										int rowCount = UD14CmdRows.Count();
										int lineNum = rowCount;
										bool goodIndex = false;
										string NoLigne = lineNum.ToString();
										while ((goodIndex == false))
										{
											// Check to see if index exists
											var UD14ExistsRow = (from exists in Db.UD14 where exists.Company == relRow.Company && exists.Key1 == sOrder && exists.Key5 == NoLigne  select exists).FirstOrDefault();
											
											if ((UD14ExistsRow != null))
											{
												lineNum = (lineNum + 1);
												NoLigne = lineNum.ToString();
											} else
											{
												goodIndex = true;
											}
										}
									 UD14 newRow = new UD14();
									 Db.UD14.Insert(newRow);
									 newRow.Company = Session.CompanyID;
									 newRow.Key1 = param1;
									 newRow.Key2 = param2;
									 newRow.Key3 = string.Empty;
									 newRow.Key4 = string.Empty;
									 newRow.Key5 = NoLigne;
									 newRow.Date01 = DateTime.Now;
									
									 newRow.Character03 = callContextClient.CurrentUserId;
									 newRow.Character04 = DateTime.Now.ToShortTimeString();
									 
									
									 Db.Validate();
									 txScope.Complete();
								}
						}
						
						
				}
		}
		

This ws kind of pseudo code, you need to add your own info!

Pierre

Epicor deletes only the record created by it. I use ChgLog for capturing usage of Reports, Dashboards, etc.
ChgLog = new Ice.Tables.ChgLog();
Db.ChgLog.Insert(ChgLog);
ChgLog.Company = Session.CompanyID;
ChgLog.Identifier = Company_c;
ChgLog.SchemaName = “Ice”;
ChgLog.TableName = “BAQDashBoard_c” ;
ChgLog.Key1 = ttDynamicQueryRow.QueryID;
ChgLog.Key2 = DateTime.Now.ToString();
ChgLog.Key3 = Guid.NewGuid().ToString();
ChgLog.DateStampedOn = DateTime.Today;
ChgLog.LogText = ttDynamicQueryRow.Description ;
ChgLog.LogNum = 1 ;
ChgLog.UserID = Session.UserID;

If its older then 2 or 3 years delete it.

OK ! I see…you are using the table ChgLog as your UD table to hold the data…I use a UD table for the same purpose…

Pierre