cancel
Showing results for 
Search instead for 
Did you mean: 

Get Date Stored using Workflow Unity API in a Workflow Process

GILBERTO_CORUJO
Champ on-the-rise
Champ on-the-rise

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
}
}

1 ACCEPTED ANSWER

Zhengxin_Guo
Confirmed Champ
Confirmed Champ

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!

 

View answer in original post

5 REPLIES 5

Zhengxin_Guo
Confirmed Champ
Confirmed Champ

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!

 

Jason
Thank you for answer me.

I'm using this porperty. But the problem is that when I run the script the keyword that represent Realname has the value. But the keyworld that represent the Time Date value is in blank and not present any error.

Jason
Thank you for answer me.

I'm using this porperty. But the problem is that when I run the script the keyword that represent Realname has the value. But the keyworld that represent the Time Date value is in blank and not present any error.

I'm using the script that I send In this post.

Ok I resolved with your help.

Thank you!!

Gilbert