07-31-2019 08:11 AM
I am adding new keywords via a ReindexProperties.AddKeyword object, this adds the keyword but the value of the keyword is not added.
I am doing it via this:
ReindexProperties.AddKeyword(keyword); //Where keyword is of type Hyland.Unity.Keyword
08-01-2019 05:36 AM
Below is a tested code example that I have confirmed. Please feel free to follow this design and let me know how it works for you. In my case, I put this into a system task for testing. It will also work as-is in a workflow action if that is more relevant for you.
public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
{
try
{
Document theDoc = args.Document;
DocumentType newDocType = app.Core.DocumentTypes.Find("the new doc type name");
if (newDocType == null)
{
throw new Exception("New Document Type not found.");
}
Storage storage = app.Core.Storage;
ReindexProperties reindexProps = storage.CreateReindexProperties(theDoc, newDocType);
if (reindexProps == null)
{
throw new Exception("ReindexProperties not created.");
}
KeywordType newKeywordType = app.Core.KeywordTypes.Find("your new keyword type name");
if (newKeywordType == null)
{
throw new Exception("New Keyword Type not found.");
}
Keyword newKeyword = newKeywordType.CreateKeyword("Smith");
if (newKeyword == null)
{
throw new Exception("New Keyword not created.");
}
reindexProps.AddKeyword(newKeyword);
Document newDoc = storage.ReindexDocument(reindexProps);
app.Diagnostics.Write("Document Successfully ReIndexed, Document ID = {0}.", newDoc.ID);
args.ScriptResult = true;
}
catch (Exception ex)
{
app.Diagnostics.Write("ERROR: {0}", ex);
args.ScriptResult = false;
}
}
Cheers!
08-01-2019 06:24 AM
I'm still getting the same object reference exception when calling ReindexDocument(reindexProps);
08-01-2019 06:32 AM
Shane's code works in my sandbox as well, which makes me think it has to be something to do with your configuration -- see below.
08-01-2019 11:56 AM
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.