03-18-2016 10:45 AM
Hi
How can I get the Date Stored of the current document using Workflow Unity API?
I appreciate your help!
Gilbert
--------------------------------------------
// Skeleton generated by Hyland Unity Editor on 3/18/2016 12:12:28 PM
namespace RealNameDataTimeScriptNote2
{
using System;
using System.Text;
using Hyland.Unity;
/// <summary>
/// RealName - DataTime Script Note(2)
/// </summary>
public class RealNameDataTimeScriptNote2 : Hyland.Unity.IClientWorkflowScript
{
#region IClientWorkflowScript
/// <summary>
/// Implementation of <see cref="IClientWorkflowScript.OnClientWorkflowScriptExecute" />.
/// <seealso cref="IClientWorkflowScript" />
/// </summary>
/// <param name="app"></param>
/// <param name="args"></param>
public void OnClientWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.ClientWorkflowEventArgs args)
{
// Add Code Here
Document currentDocument = args.Document;
DocumentLock lockInfo = null;
try
{
User user = currentDocument.CreatedBy;
string name = user.RealName;
//string name = app.CurrentUser.RealName;
//string email = app.CurrentUser.EmailAddress;
DateTime DateandTime = currentDocument.DateStored;
//string displayName = user.DisplayName;
string keyword = "STU-NCFE Realname";
string keyworddatetime = "STU-NCFE Date and Time";
//app.Diagnostics.Write("Name: " + name);
//app.Diagnostics.Write("Real Name: " + realName);
//app.Diagnostics.Write("Display Name: " + displayName);
//string name = app.CurrentUser.RealName;
//string email = app.CurrentUser.EmailAddress;
lockInfo = currentDocument.LockDocument();
if (lockInfo.Status == DocumentLockStatus.LockObtained)
{
KeywordModifier keywordMod = currentDocument.CreateKeywordModifier();
keywordMod.AddKeyword(keyword, name);
keywordMod.AddKeyword(keyworddatetime, DateandTime);
app.Diagnostics.Write(keyword + ": " + name);
keywordMod.ApplyChanges();
}
else
{
app.Diagnostics.Write("Document already locked by: " + lockInfo.UserHoldingLock.DisplayName);
}
}
catch (UnityAPIException e)
{
app.Diagnostics.Write(e);
}
catch (Exception ex)
{
app.Diagnostics.Write(ex);
}
finally
{
if (lockInfo != null)
{
lockInfo.Release();
}
}
}
#endregion
}
}
03-18-2016 12:23 PM
Hi! Gilberto,
The property Hyland.Unity.Document.DateStored should give you the date time of the document was stored.
Hope this answers your question. Please let me know if you have any questions. Thanks!
03-18-2016 01:46 PM
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.