cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a time delay in KW update from Unity Automation API?

Scott_Johnson3
World-Class Innovator
World-Class Innovator

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

11 REPLIES 11

Rob_Biddle
Star Contributor
Star Contributor

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

Scott_Johnson3
World-Class Innovator
World-Class Innovator

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

Scott_Johnson3
World-Class Innovator
World-Class Innovator

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

Michael_Shuste1
Champ in-the-making
Champ in-the-making

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.

Seth_Yantiss
Star Collaborator
Star Collaborator

[quote user="scott"] I created a extra work queue...

Creative approach!

Cheers,
Seth