02-12-2013 05:26 PM
Hi All
I am on 12.0.1.154 core. I have a unity automation script that updates keywords as part of a workflow timer work. Then later in the timer work, it tests one of those keywords to see of it is > 3.0. The rub is the KW seem to the null when I get to the rule. But when the system work is complete the KW has the proper value. Is there some locking going on? How do I get at those newly computed KWs in my timer work?
Thanks
Scott
02-13-2013 08:19 AM
Scott,
My understanding is that one should always attempt to obtain a document lock before changing any keyword values on a document. I believe this is in order to be sure that there aren't any other user locks on that document that moment, and in order to lock the document during your keyword changes -- I'm not aware of any locks being put on the document automatically. Although I guess a process running a timer which has Rules or Actions which change keyword values would be locking the document also.
Anyway... here's a code sample showing an example of changing keyword values (C#). This example is actually removing keywords, but the idea is basically the same whether you're adding, updating, or removing keyword values. 'args' is a Hyland.Unity.WorkflowEventArgs object.
1. obtain DocumentLock and check that its Status is not 'AlreadyLocked'
using (DocumentLock objDocLock = args.Document.LockDocument())
{
if (objDocLock.Status == DocumentLockStatus.AlreadyLocked)
{
// do not attempt to update/remove keywords, otherwise, continue
}
2. create the KeywordModifier object
KeywordModifier objKeyModifier = args.Document.CreateKeywordModifier();
3. work on your keywords (update/remove/etc)
foreach (KeywordRecord objKeyRecord in args.Document.KeywordRecords.FindAll(objKWRecType))
{
objKeyword = objKeyRecord.Keywords.Find(objKWTypeAppTime);// there is only one
{
if (objKeyword.DateTimeValue.CompareTo(this.ApprovalTime) >= 0)
{
objKeyModifier.RemoveKeywordRecord(objKeyRecord);
}
}
}
4. apply changes via the KeywordModifier (otherwise they are lost)
objKeyModifier.ApplyChanges();
5. release DocumentLock (in this example the release occurs at closing brace of 'using' block)
}
I hope that's helpful,
Rob
02-13-2013 10:40 AM
Hi Rob
Thanks so much for your reply. I added the lock code and still the workflow cannot get the updated keywords, I think it is time to call support.
Scott
02-13-2013 01:23 PM
To anyone interested,
I found a brute-force work-around this random Hyland "feature" that I hope they "change" in a future . I created a extra work queue with a second timer service. The first timer service calls the unity automation script and transitions the doc to the new queue. The second timer service does the rest of the work.
Scott
02-13-2013 01:43 PM
Did you make sure you checked the "refresh document" checkbox that is part of the rule/action that runs your unity script. If you do not check that, OnBase will continue the timer work with the document/keywords that it has in memory before your script ran.
02-13-2013 02:02 PM
[quote user="scott"] I created a extra work queue...
Creative approach!
Cheers,
Seth
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.