Report Styles and attaching to SharePoint

Hi, I am looking to store our documents in SharePoint rather than Docstar ECM (having major issues with their support and missing documents etc).

Manual attachments are fine but I am really hoping we can use something similar to Report Style Break/Routing to store files created by Epicor within a SharePoint library based on the Document Type ID but im struggling to find any methods.

Has anyone set this up before?

Could you explain a bit more what you are wanting to do?

I’ve worked a bit lately with SharePoint so maybe I can help.

Hi, i want to emulate the Docstar ECM attachment widget in the Breaking and Routing designer but instead of ECM I want to store the file in a SharePoint library.

1 Like

Just to add, i have tried a BPM to create the XFileRef and XFileAttach records and then use PowerAutomate to copy the attachment once we send an email.

The records created but the attachment does show on the Customer record.

I would rather have a solution that is driven purely out of epicor.

1 Like

I think I can help. Let me get to work and get settled in and I’ll be back.

1 Like

Great news. :partying_face:

Haven’t forgot you. Trying to find an appropriate report to set up some APR tests on.

Ok, I do not have the control I thought I did.

There is a BPM that is fired that you can override with the ecm attachment, however, I thought the check for if we have ecm was at the bpm level.

It is not, I can’t add that widget, so no firing the bpm to intercept.

If you want to attach the documents, we’ll have to find another intercept point that makes sense.

Attaching the documents is pretty straightforward once you have all the info about where etc.

1 Like

Hi, thanks for looking into it.

There is a check box that triggers the attachment to be sent in an email if that can be used?

Could you explain in full what you would want?

This may be a shot in the dark but if you are saving the attachments to a specific folder you could use a power automate workflow to grab them and add them to SharePoint?

Order Acknowledgement and Custom Report PDF attached per sales order and stored in a sharepoint library.

As for triggers, a UD boolean field goign from false to true would trigger a bpm.

You have this set up already? Where and when is it triggered?

Yeh this is set up, its on the Order Entry Screen as part of a custom validation.
Manually triggered per order. The current DocStar automation uses this

1 Like

Cool beans.

I’ve got a deployment of a project today that has pretty much everything you need. When I get in there later I’ll pull out the relevant bits.

1 Like

Brilliant :slight_smile:
I look forward to hearing from you.

Thank you so much.

This is pulled verbatim from a function I’m using to snapshot engineering documents to jobhead.

Dictionary<string, string> dctEngineeringDocuments = JsonConvert.DeserializeObject<Dictionary<string, string>>(engineeringFilesReturn.fileDictionaryDataB64);

CallService<Erp.Contracts.JobEntrySvcContract>( jobEntry =>
{

    Erp.Tablesets.JobEntryTableset jobTS = new Erp.Tablesets.JobEntryTableset();
            
    CallService<AttachmentSvcContract>(attachSvc =>
    {
        string prefix = DateTime.Now.ToString("MM_dd_yyyy");
    
        foreach(var engineeringDoc in dctEngineeringDocuments.Where(x => x.Key.ToLower().EndsWith("pdf")))
        {
            
            string filename = $"SS_{jobNum}_{prefix}_{engineeringDoc.Key}";
            
            string returnFilename = attachSvc.SpUploadFile(filename, Convert.FromBase64String(engineeringDoc.Value), "ECO", "JobHead", new Dictionary<string, string>());
            
            jobEntry.GetNewJobHeadAttch(ref jobTS, jobNum);
            
            var newAttachment = jobTS.JobHeadAttch.Where(x => x.RowMod == "A" && String.IsNullOrEmpty(x.FileName)).FirstOrDefault();
            
            newAttachment.FileName = returnFilename;
            //newAttachment.DocTypeID = "ECO";
            newAttachment.DocTypeID = attachmentDocType;
            
            string truncFileName = engineeringDoc.Key.Length > 100 ? engineeringDoc.Key.Substring(0, 100) : engineeringDoc.Key; 
            
            newAttachment.DrawDesc = truncFileName;
        }      
    });
    
    jobEntry.Update(ref jobTS);
    
    if(lockIt == true)
    {
        Db.JobHead.Where(x => x.JobNum == jobNum).FirstOrDefault().JobSnapshotLocked_c = true;
        Db.SaveChanges();
    }
   
});

The relevant bits for you are here: (You may need to look at the whole code though.)

    CallService<AttachmentSvcContract>(attachSvc =>
    {
        string prefix = DateTime.Now.ToString("MM_dd_yyyy");
    
        foreach(var engineeringDoc in dctEngineeringDocuments.Where(x => x.Key.ToLower().EndsWith("pdf")))
        {
            
            string filename = $"SS_{jobNum}_{prefix}_{engineeringDoc.Key}";
            
            //NOTICE: Uploading file to SharePoint
            string returnFilename = attachSvc.SpUploadFile(filename, Convert.FromBase64String(engineeringDoc.Value), "ECO", "JobHead", new Dictionary<string, string>());
            
            jobEntry.GetNewJobHeadAttch(ref jobTS, jobNum);
            
            var newAttachment = jobTS.JobHeadAttch.Where(x => x.RowMod == "A" && String.IsNullOrEmpty(x.FileName)).FirstOrDefault();
            
            newAttachment.FileName = returnFilename;
            //newAttachment.DocTypeID = "ECO";
            newAttachment.DocTypeID = attachmentDocType;
            
            string truncFileName = engineeringDoc.Key.Length > 100 ? engineeringDoc.Key.Substring(0, 100) : engineeringDoc.Key; 
            
            newAttachment.DrawDesc = truncFileName;
        }      
    });

If you need further explanation, let me know.

Hurry up Ricky, I need to know if that code works before I put mine in production.

I ain’t got no time for testing and stuff.

4 Likes

I have had a go at the code but im struggling to convert this toa Data Directive on the Order Hed table.

I dont have anything to replace the dctEngineeringDocuments and the attachment service cant be found after i added the attachments BO.

1 Like

Ok, you need more help.

I’ll be back.