Is there a way to access the Result File returned by the Download Electronic File activity in Workflow when using the SDK Script activity? GetTokenValue("result file") is returning a Laserfiche.Workflow.Common.FileBookmark type, and I'm trying to turn this into an ordinary System.IO.FileInfo type. Any help would be appreciated!
Question
Question
Access Download Electronic Document Result File from SDK Script Activity
asked on December 12, 2018
1
0
Answer
SELECTED ANSWER
replied on December 12, 2018
•
Show version history
I would skip the Download Electronic File activity entirely and just use a stream reader to extract the file directly from the document in the SDK Script.
The following is an example of how to do that:
// Get bound entry as DocumentInfo object DocumentInfo doc = (DocumentInfo)this.BoundEntryInfo; // Set output path string outputFile = @"\\hostname\C$\temp\test"; // Set result variable to detect errors/failure bool docExported = false; try { // Check for electronic document if(doc.IsElectronicDocument){ // Get document extension string ext = doc.Extension; // Read eDoc and save to external location string mimeType = ""; // You can use either file stream or memory stream depending on what you need to do //MemoryStream ms = new MemoryStream(); FileStream fs = new FileStream(outputFile + "." + ext, FileMode.OpenOrCreate); using (LaserficheReadStream eDocStream = doc.ReadEdoc(out mimeType)){ // Copy eDoc to the stream eDocStream.CopyTo(fs); } // Set success result docExported = true; } // If source document has no eDoc else{ // handle "error" } } finally { // Track results token SetActivityTokenValue("DocExported",docExported); }
Just make sure you add a reference to Laserfiche.DocumentServices and that your workflow service account has access to wherever you're trying to put the file.
NOTE: When testing it from the script editor it will run as you and use your permissions, so you might see different results when actually running it in the workflow.
Although it is possible to access the result file, those are stored to a temporary path and I've seen situations in which temporary resources like those are removed/lost before the script can actually run.
4
0
Replies
You are not allowed to reply in this post.
You are not allowed to follow up in this post.