You are viewing limited content. For full access, please sign in.

Question

Question

Use Workflow SDK Script export "msg" file failure -- anyone can help diagnosis the error message?

asked on September 17, 2021

Hi all, recently I created a Laserfiche workflow and use SDK script ( courtesy to https://answers.laserfiche.com/questions/148898/Workflow-to-Export-Document-to-Windows-Folder#166292 ) to export documents in a repository to windows folder. Most of the documents have no issues but some of the "msg" file (outlook email item) are unable to export. 

The code section like this

private void ExportElectronic(DocumentInfo LFDoc, String sExportFolder)
{
    try
    {
        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(sExportFolder);
        if (!di.Exists)
        {
            di.Create();
        }
        DocumentExporter docExporter = new DocumentExporter();
        String exportPath = System.IO.Path.Combine(sExportFolder, LFDoc.Id + "." + LFDoc.Extension);
        docExporter.ExportElecDoc(LFDoc, exportPath);
    }
    catch (Exception ex)
    {
        WorkflowApi.TrackError(ex.Message);
    }
}

When check the workflow result of failure exporting scenario, the exception shows

 

Can some one tell me what could be the problem with the documents in repository?

 

BTW, if I drag & drop the document from LF windows client, and then import the document back to Laserfiche, the export workflow has no issue work with the copy. So definitely not the document (msg) itself. Plus not all "msg" type documents has the problem.

 

Any input would be helpful. Thanks

 

0 0

Replies

replied on September 17, 2021 Show version history

Hi Luke, you can try following and see what the results are:

private void ExportElectronic(DocumentInfo LFDoc, String sExportFolder)
        {
            try
            {
                //I found this needs to be called in order to access properties like Extension 
                //And it should also tell if LFDoc is null or not
                LFDoc.Refresh(true);
            }
            catch (Exception ex)
            {
                WorkflowApi.TrackError("LFDoc problem: " + ex.Message);
            }
 
            try
            {
                System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(sExportFolder);
                if (!di.Exists)
                {
                    di.Create();
                }
                DocumentExporter docExporter = new DocumentExporter();
                String exportPath = System.IO.Path.Combine(sExportFolder, LFDoc.Id + "." + LFDoc.Extension);
                docExporter.ExportElecDoc(LFDoc, exportPath);
            }
            catch (Exception ex)
            {
                WorkflowApi.TrackError(ex.Message);
            }
        }
1 0
replied on September 17, 2021

Thank you Tomas, that's an interesting find - I'll try it out and report back. 

0 0
replied on September 20, 2021

Hi Luke,

 

If you're still not getting joy from your own code, you can also try our Workflow Activity Bundle, it includes an activity to export a Laserfiche Entry to Windows. You can download a trial and play around here.

1 0
replied on September 17, 2021

Forgot to mention, it's part of workflow and the feeding "LFDoc" in the call are valid LF entry return by "Find entry" activity.

0 0
replied on September 17, 2021

LFDoc is really the only object reference that is accessed in the code; if sExportFolder were null I would expect a different error. Are you certain that it's not null? Maybe add some logging to verify.

1 0
replied on September 17, 2021 Show version history

There are other code blocks (not in this workflow but another standalone program use the exact same API calls)  that dealing the same entry that handle version and meta fields exporting and they all success without reporting error -- that is saying, the "DocumentInfo" structure I passed in should be valid unless the electronic contents has some issue. Again it happens only to "msg" type documents (not all "msg" though), and it only happens to that production repository -- the code/workflow run on dev, test environment with copy of those questionable "msg" files has no issue at all. That is the hardest part for me to do debugging.

I'll see if I can break-down calls a little bit add more print/log.

0 0
replied on September 21, 2021 Show version history

Update:  we put some logging and finally identify the issue. It's not about the Export API problem but it's the "DocumentInfo"  object that related to those "msg" file, their MIME info (in database) isn't set correctly (not sure why), thus the detection of "LFDoc.IsElectronicDocument" returns wrong category, and end up export an empty document.

As a quick/dirty remedy of our solution, we just ignore the type and use its extension "msg" to export as electronic document.

Thank  you all for input your comments.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.