cancel
Showing results for 
Search instead for 
Did you mean: 

Adding value to Keyword which is multi-instance and part of Keyword Type Group

Ryan_Wilson2
Star Contributor
Star Contributor

I am trying to add a value when indexing a document through the API using StoreNewDocumentProperties.AddKeyword(string keyword, string value), but I keep getting an error that it cannot store a null value. The keyword is multi-instance and part of a Keyword Type Group with the same name. All other keywords are storing correctly. If I omit this one, is there a special way to handle these and if so, can someone help me out?

2 ACCEPTED ANSWERS

Shane_Cook1
Star Contributor
Star Contributor

Yes, There is a special way because the keyword is part of a keyword type group.  Bottom line is that you need to create an editable keyword record type (KRT) object then add keyword(s) to the KRT.

Here is a previous answer with more complete pseudocode you need to do what you asked for. 

Add Multi Instance Keyword Records through API

Cheers.

View answer in original post

Mohd_Amir_Ziya
Confirmed Champ
Confirmed Champ

Hi Ryan,

I am agree with Shane's answer, you need to create EditableKeywordRecord for multi instance record type. Use below code if it can help you.

KeywordModifier keymode = Doc.CreateKeywordModifier(); if (keyRec.KeywordRecordType.RecordType != RecordType.MultiInstance)	{		keymode.AddKeyword(keyword type, keyword value);        }else	{		EditableKeywordRecord editKeyRec = keyRec.CreateEditableKeywordRecord();                editKeyRec.AddKeyword(keyword type, keyword value);                keymode.UpdateKeywordRecord(editKeyRec);        }keymode.ApplyChanges();

Regards,

Amir

View answer in original post

2 REPLIES 2

Shane_Cook1
Star Contributor
Star Contributor

Yes, There is a special way because the keyword is part of a keyword type group.  Bottom line is that you need to create an editable keyword record type (KRT) object then add keyword(s) to the KRT.

Here is a previous answer with more complete pseudocode you need to do what you asked for. 

Add Multi Instance Keyword Records through API

Cheers.

Mohd_Amir_Ziya
Confirmed Champ
Confirmed Champ

Hi Ryan,

I am agree with Shane's answer, you need to create EditableKeywordRecord for multi instance record type. Use below code if it can help you.

KeywordModifier keymode = Doc.CreateKeywordModifier(); if (keyRec.KeywordRecordType.RecordType != RecordType.MultiInstance)	{		keymode.AddKeyword(keyword type, keyword value);        }else	{		EditableKeywordRecord editKeyRec = keyRec.CreateEditableKeywordRecord();                editKeyRec.AddKeyword(keyword type, keyword value);                keymode.UpdateKeywordRecord(editKeyRec);        }keymode.ApplyChanges();

Regards,

Amir