cancel
Showing results for 
Search instead for 
Did you mean: 

Unity API equiv of CopyLocal?

Cameron_Gray
Champ on-the-rise
Champ on-the-rise

Hey guys,

I am currently re-writing a tiny script that was hidden in a workflow for a customer we just upgraded from OnBase 13 to OnBase 15.02.

The VBScript was being called with SYS -Run Script in a workflow, and what it would do is copy the target document to a network share and modify the file name at that location. An example would be if the item in workflow was Document A 12345 10/03/2016 it would be copied out to the provided network share as DocumentA1234510_03_2016. The script was using the 'CopyLocal' method which doesn't seem to exists any longer in Unity API.

I see there's a workflow action in OnBase 15 'Export to Network Share', but it doesn't look like I would be able to modify the output of the filename using that workflow action. Is there some functionality to accomplish this in the Unity API that I am missing?

Thanks,

Cameron

1 ACCEPTED ANSWER

Paul_Lloyd
Employee
Employee

You can use Export to Network Location, configured to set the filename from a property.

You can set the property to your modified filename by using the Set Property to Expression Workflow Action.

Here's a screenshot of a sample workflow:

In the Set propOriginal to Original Doc Name Action, I use Set Property Value to set a property to the current document name:

Next, I use Set Property to Expression to replace "/" with "_", and remove spaces:

I test it using your example:

 

Finally I use Export to Network Location and set the filename to propName:

View answer in original post

14 REPLIES 14

William_Hobeck
Star Contributor
Star Contributor

You can use something like this:

                // Get the default rendition of the current revision of the document
                // Need a rendition to retrieve the page data.
                Rendition currentRendition = document.DefaultRenditionOfLatestRevision;
              
                // Use the Retrieval class.
                // Returns file data directly from the diskgroups when we use "Native format."
                using (PageData pageData = core.Retrieval.Native.GetDocument(currentRendition))
                {

                     // String used for name of document saved to the file system.  pageData.extension gives you the document extension
                     string fileExtension = "." + pageData.Extension;
                     string fileName = @"C:\test";

                    // Use the Utility class to write the page data stream to the desired file
                    Utility.WriteStreamToFile(pageData.Stream, fileName + fileExtension);
                }

Thank you!!  This saves me so much time to be able to use your example!!  

Robert_Angus
Star Contributor
Star Contributor

Cameron,

There isn't a single method to do this in Unity, you would need to go through the typical means of getting a document's PageData and then getting the stream and writing it out to a file.

You could also maybe use the "Export to Network Location" action and specify the filename using a property. You should be able to pretty easily customize the property using the "Set Property to Expression" action.

Yeah, I think this can be done without a script by using properties. I believe another action that can do this is Send Web Request. It sounds weird, but there is a file:\\ protocol option. I think this may not work if there are different extensions going through this action - I don't recall if there is a method to get the extension using set property value/expression.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.