cancel
Showing results for 
Search instead for 
Did you mean: 

AddKeyword/ApplyChanges() not triggering AutoName change

Brett_Booz
Star Contributor
Star Contributor

I'm using the API to write a series of documents to OnBase using the Unity API. In some cases I have to go back an add keywords to the newly created documents because they were unknown at the beginning of the process. The keywords are getting added correctly, however the AutoName string on the Document does NOT get updated?

Here's the code I'm using to make the change:

using (DocumentLock docLock = PackageDoc.LockDocument())
{
    
if (docLock.Status == DocumentLockStatus.LockObtained)
    
{
        
KeywordModifier MemberNoKWModifier = PackageDoc.CreateKeywordModifier();
       
MemberNoKWModifier.AddKeyword(MemberNoKW);
        
MemberNoKWModifier.ApplyChanges();
     }

}

Is there something I need to do after the ApplyChanges() or an option I need to set before ApplyChanges() that would affect an update to the AutoName string?

Thanks!

Brett Booz
Systems Analyst
Spokane Teachers Credit Union (STCU)

5 REPLIES 5

Zhengxin_Guo
Confirmed Champ
Confirmed Champ

Hi! Brett,

 

The Untiy API would trigger the autoname when keywords gets updated.

 

In the code, if we change the code like this:

     MemberNoKWModifier.UpdateKeyword(oldKW, MemberNoKW);

Both the keyword and document name should be updated.

It seems that KeywordModifier.AddKeyword would add a new keyword of the same type to the document if the document has the keyword in this type already. It will not trigger the autoname since there is no keyword updated but added.

If you have any questions. Please let me know!

-Jason

To add on to Jason's reply, if you want to update your auto-name when ADDING a new keyword, you need to change the auto-name string in the configuration to allow repeats. When you add a keyword type to auto-name string in configuration you would notice that it will be added like "%K00002.1". The number after the "." represents number of values of the same keyword type to appear in the auto-name string. So if you change it to "%K00002.n", then "n" values of that keyword type will be added. More information about configuring auto-names can be found in System Administration MRG. Care should be taken when allowing repeats, as it would easily increase the length of the auto-name string thus making it difficult to read. Also the maximum number of characters allowed in an auto-name string is 255.

That kind of makes sense, but in this case the document doesn't have the keyword to modify. I am adding the KW for the first time, so there is no oldKW to update. Is the UpdateKeyword method smart enough to add a keyword if the oldKW doesn't exist or does it through an error?

From my experience, the UpdateKeyword method would add a keyword if the oldKW doesn't exist.
Getting started

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.