Below is an OnBase unity workflow script to export a doc to the directory. Be sure to add the References that you are using.
namespace _SaveToFile
{
using System.IO;
using System.Text;
using System;
using Hyland.Unity;
using Hyland.Unity.Workflow;
/// <summary>
/// script for doing something in a workflow
/// </summary>
public class _SaveToFile : Hyland.Unity.IWorkflowScript
{
#region IWorkflowScript
//<summary>
// Implementation of the export to file share of the 3M integration
// </summary>
/// <param name="app"></param>
/// <param name="args"></param>
public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
{
try
{
Document wfdoc = args.Document;
//Application _app = app;
string url = "<application service URL";
string username = "<manager account";
string password = "<manager password";
string datasource = "DSN of OnBase database";
//Create a new Unity Integration Application Object
OnBaseAuthenticationProperties props = Application.CreateOnBaseAuthenticationProperties(url, username, password, datasource);
props.LicenseType = LicenseType.Default;
Application _app = Application.Connect(props);
string dirPath = @"\\FileServer\Share\" + args.Document.ID + ".";
// create Redition
Rendition wfrend = wfdoc.DefaultRenditionOfLatestRevision;
//PageData
using (PageData wfPageData = _app.Core.Retrieval.Image.GetDocument(wfrend))
{
//Utility to write data page stream
Utility.WriteStreamToFile(wfPageData.Stream, dirPath + wfPageData.Extension);
}
args.ScriptResult = true;
_app.Disconnect();
}
catch (UnityAPIException Uex)
{
app.Diagnostics.Write("Unity API: "+Uex.Message);
args.ScriptResult = false;
}
catch (Exception ex)
{
app.Diagnostics.Write("Exception: "+ex.Message);
args.ScriptResult = false;
}
}
#endregion
}
}
John, could you post a unity script to retrieve data from an API service and update a textbox field on a Unity form?
ReplyDelete