Does integration 'E10_Attach File to ERP' have a version option?

,

I’ve got a workflow that attaches a file to a record in Epicor. I would like to automate the workflow but am concerned about versioning/revisions getting attached to the same Epicor record as a new document instead of a new version of the existing one. I’ve generated a SQL statement that will identify if there is already a record but I don’t know how to version the current document? I don’t see anywhere to put in the XFileRefNum in to identify it as the same record.

Am I missing something or is this not an option?

1 Like

This is actually an open ticket of mine right now. I’m waiting for the answer, but so far I can tell you that it will not automatically (or optionally) version documents.

My testing has also shown that the workflow has no commands to do versioning, nor does the ECM client batch import process. Nor does attaching it from inside the ERP UI.

The only two ways to version a document currently is manually via the UI, and interestingly, it automatically versioned when using Advanced Print Routing in the Print Style in ERP.

3 Likes

In 21.1 they added custom version numbers which you enable in Content builder. According to the relase notes at the link below the client would get a dialog of the version and have the ability to change it. I would enable it on a dev system and then attach the same document a few times to see if it triggers.

https://epicweb.epicor.com/doc/Docs/Epicor%20ECM%20(DocStar)%20What’s%20New.pdf

In my 10.2.400 sysconfig there is a DocStar duplicate attachment setting of autoversion or prompt, so there has to be a default system level setting somewhere.

You’re correct Greg - but those release notes specifically detail that you can only control the format of the version number, not the process to generate it.

That sysconfig entry is exactly what allows the ERP UI to work correctly. I did misspeak earlier and say that the UI won’t do it - it will because of that setting - but there is no control of that inside the UI to make it specific to a Doc Type - that I have found yet. And the APR “put Document” widget does it automatically - no manual control - and it doesn’t use the sysconfig setting because mine is set to prompt yet the widget automatically versions.

Just got off the phone with Epicor Support. He confirms that our information here is correct, and that he does not know if any additional control over versioning is ‘in the pipeline’. he’s going to do some research and get back to us.

Also - anyone know how to delete a document in the workflow? how about “Un-Attach a File from ERP”? These two things are also not available and I’ve asked him to look into these as well.

1 Like

True, but it would give you a clue that it was versioning if the dialog came up. I am working on SOA today, so I just set them and will see if they do anything.

Using a search task then Remove from folder or remove from all folders should be able to remove the document from ECM. With the documentID as a parameter a datalink to remove the xfileref record should clear the attachment.

You’re in Nashville right? Let’s compare notes!

The dialog comes up in the ERP UI’s File Attach process if the sysconfig is set to ‘prompt’ but it doesn’t give you any control over the version numbers - it just asks if you want to create a new version or a new document. And as far as I know, the only place you can create custom version #s is inside ECM after you turn on that checkbox.

Remove from All folders doesn’t actually remove it from ECM completely - we use it in most of our workflows to move documents from the temp workflow location to it’s final place. We use a combination of Remove from All Folders and Add to Folder tasks because there is no ‘move to folder’ task.

Also, since is no Delete task, I found that you cannot use the Recycle Bin as the destination of Add to Folder…

Are you saying create a datalink that is actually a SQL delete statement? I suppose that would work, but can you even do that? It would have to touch both the xFileRef and xFileAttach tables but it also violates the Epicor Prime Directive - no direct DB manipulation. I’d rather have someone wrap the ERP REST document attach API calls in a few datalinks within the integration - that way there is no worry on my part and Epicor can support it.

We can discuss in Nashville and drop by the ECM room to advocate for a REST task or additions to the toolset.

1 Like

Sounds like a plan!

1 Like

I have just run into this same problem.

Before I go ahead and try it, does anyone know if I create an attachment through a function if it will auto version?

1 Like

Hi.
I am not sure if this helps here but I have found a solution to the issue I was facing. I had a batch import that was running from the client service, creating and indexing a document in ECM (DocStar) and then creating the record in ERP. But I had this issue in that a new version of a file could be imported but it would not create a new version.

What I have done instead is turn the process around and I am importing the file from a scheduled EPICOR Function instead. This way I can use the method DocStarFileExistsForTableRow to see if the file already exists and then either DocStarUploadFile if the fine does not exist, or DocStarUploadFileAsVersion if the file does exist.

It seems to work perfectly this way.

Hope this helps, I know it’s not exactly the same scenario.

2 Likes

Good stuff Steve!
We’ve talked before on here about how the client can recognize and do the versioning if the client’s sysconfig file setting is turned on. I never knew the exact method calls until now, and I’m going to see if something like this might work for a few of our doc types.

Any chance you might share you EFx? I think a handful of folks here might find some use in it.

1 Like

My code is still a bit untidy while we are testing but once tidied up a bit I will post it up :smiley:

1 Like

try
{
int iOrderNum = System.Convert.ToInt32(this.orderNum);
int iOrderLine = System.Convert.ToInt32(this.orderLine);

var oHedGuid = new System.Guid();
string strfolder = @“C:\INPUT_FOLDER”;
string strProcessedFolder = @“C:\PROCESS_FOLDER”;
string strINSFileName = this.partNum + “.jpg”;
string strINSOrigFileName = this.partNum + “.jpg”;
string strFullFilePath = strfolder + strINSFileName;
bool bFileExists = false;

string strXfileName = “”;
int iAttachNum = 0;
int iXFileRefNum = 0;

//find the guid for the row we want to add the attachment to

var orderHedRow = Db.OrderHed.FirstOrDefault(odtl=> odtl.Company == Session.CompanyID && odtl.OrderNum == iOrderNum);
if (orderHedRow != null)
{
oHedGuid = orderHedRow.SysRowID;
}

//make sure the file exists

string inspFileExists = System.IO.File.Exists(strFullFilePath).ToString();

if (inspFileExists == “True”)
{
//covert the file to byte array
var bytes = System.IO.File.ReadAllBytes(strFullFilePath);
//initiate the attachments service

 this.CallService<Ice.Contracts.AttachmentSvcContract>(attch=>
              {
                               
                //check to see if the file exists 
                attch.DocStarFileExistsForTableRow("DOOR_IMG", "OrderHed",strINSFileName,oHedGuid, out strXfileName, out iAttachNum);
                //if the file exists it will return an attachment number
                if (iAttachNum > 0)
                  {
                  bFileExists = true;
                  //find xFileRefNum
                  //I'm not sure if this can be found from the method or if DB lookup is the only way
                  var XFileAttch = Db.XFileAttch.FirstOrDefault(x=> x.Company == Session.CompanyID && x.AttachNum == iAttachNum);
                  iXFileRefNum = XFileAttch.XFileRefNum;
                  }

                 System.Collections.Generic.Dictionary<string, string> mylist = new System.Collections.Generic.Dictionary<string, string>();
                 //The file exists to we want to upload a new ECM Version
                 
                 if (bFileExists)
                  {
                    var attachDataSetVer = attch.DocStarUploadFileAsVersion(iXFileRefNum, strINSFileName, bytes, "DOOR_IMG","OrderHed",mylist);
                    
                 //   strINSFileName = attachDataSetVer.ToString();

                  }
                 else
                 {
                 //File does not already exists so create new ECM Attachment (note that this creates the ECM record but not the ERP Record)
                   var attachDataSet = attch.DocStarUploadFile(strINSFileName, bytes, "DOOR_IMG","OrderHed",mylist );
                 //return the ECM File name  
                   strINSFileName = attachDataSet;
                 }
                //initiate the sales order entry service
                this.CallService<Erp.Contracts.SalesOrderSvcContract>(
                                                        od=>
                                                            {
                                                             var odDs = od.GetByID(iOrderNum);
                                                             //od.GetNewOrderDtlAttch(ref odDs, iOrderNum, iOrderLine);
                                                             od.GetNewOrderHedAttch(ref odDs, iOrderNum);
                                                             
                                                             
                                                             if (odDs != null && bFileExists == false)
                                                                {
                                                                //loop not required in this instance but could be for other attachment types
                                                                
                                                                 var dsAtt = odDs.OrderHedAttch.Where(row=> row.RowMod == "A");
                                                                    foreach (var dsAttRow in dsAtt)
                                                                      {
                                                                          //The file name is the ECM File name
                                                                          dsAttRow.FileName = strINSFileName;
                                                                          dsAttRow.DrawDesc = "Door Image - " + this.partNum;
                                                                          dsAttRow.DocTypeID = "DOOR_IMG";
                                                                                     
                                                                      }
                                                                      
                                                                    od.Update(ref odDs);
                                                                
                                                               }
                                                                
                                                           //od end
                                                         });
                                                             
                                                 //attch end  
                                                        
                                              });
   //tidy up the files that we just processed
                                                        
  if (System.IO.File.Exists(strProcessedFolder + strINSOrigFileName))
  {
  System.IO.File.Delete(strProcessedFolder + strINSOrigFileName);
  System.IO.File.Move(strfolder + strINSOrigFileName,strProcessedFolder + strINSOrigFileName);
  }
  else
  {
  System.IO.File.Move(strfolder + strINSOrigFileName,strProcessedFolder + strINSOrigFileName);
  }
}

}
catch (Exception ex)
{
//throw; //silent fail
Ice.Diagnostics.Log.WriteEntry(String.Format("Dev Environment - Order attachment process ERROR: " + ex.Message)); //write to Event Log

            string strErrorEmailSubject = "Dev Environnment - Order attachment process ERROR: " + this.orderNum ;
            var mailer = this.GetMailer(async: true);
            var message = new Ice.Mail.SmtpMail();
            message.SetTo("support teams email address");
            message.SetSubject(strErrorEmailSubject);
            message.SetBody("There was an error attaching the image: " + ex.Message);
            mailer.Send(message);             
            
            
        }
3 Likes

Here’s my function. It is actually pretty simple I call this function from another process and pass in an order number and line as parameters but no reason why you couldn’t use a watch folder or something and run this as a scheduled function.

I am happy to recieve critique on this, it’s all a learning curve and one thing I have not worked out yet is how to pass in some keyword data to help me process the document once it hits ECM. I am sure it’s possible, I just haven’t figured it out yet.

So… I moved companies from when I originally posted this and no longer have need of the solution. I would be open to another user letting me know if it works and marking it as a solution though.

@bill.hoeppner this may be something you want to take a look at.