07-09-2016 01:24 AM
Hi All,
I am trying to validate few of the keyword types which are already configured for a document type. I have started with validating a keyword with empty check.
But the script is not working as expected. The script is getting triggered while clicking the "Upload" button in Unity but the expected result is not arrived. Dont know what i am doing wrong. Please help me. Below is the script.
FileImportKeywordPanel keywordPanel = args.KeywordPanel;
KeywordType keywordType = app.Core.KeywordTypes.Find("Serial Number");
if(keywordType == null)
{
throw new Exception("Could not find serial number keyword type");
}
KeywordRecord keywordRecord = keywordPanel.KeywordRecords.Find(keywordType);
if(keywordRecord == null)
{
throw new Exception("Could not find serial number keyword type in keyword record");
}
try
{
Keyword keyword = keywordRecord.Keywords.Find(keywordType);
if ((keyword == null) || (keyword.IsBlank))
{
MessageBox.Show("Please fill the Serial Number", "Validation", buttons);
args.ScriptResult = DocumentFileImportPreArchiveScriptResult.Cancel;
return;
}
}
catch(UnityAPIException unityEx)
{
app.Diagnostics.Write(unityEx.ToString());
}
With Regards
LMK
07-09-2016 10:11 AM
Hi LMK,
keywordPanel.KeywordRecords.Find(keywordType) isn't returning a keyword record because the keyword is blank. To get the functionality that you want, you can use: keywordPanel.KeywordRecords.Find(kr => kr.KeywordRecordType.KeywordTypes.Contains(keywordType)).
This behavior is due to the way that blank standalone keywords are handled. When the keyword is blank, it is not present in the keyword record. Only keywords with values are included in the standalone keyword record. Find(keywordType) looks for a keyword record which contains a keyword of the type in it. Since the keyword is blank, it does not find any keyword records. Using the keyword record type lets you find a keyword record which is configured to contain a keyword type, regardless of whether that keyword is currently present in the keyword record or not.
Hope this helps!
07-09-2016 10:11 AM
Hi LMK,
keywordPanel.KeywordRecords.Find(keywordType) isn't returning a keyword record because the keyword is blank. To get the functionality that you want, you can use: keywordPanel.KeywordRecords.Find(kr => kr.KeywordRecordType.KeywordTypes.Contains(keywordType)).
This behavior is due to the way that blank standalone keywords are handled. When the keyword is blank, it is not present in the keyword record. Only keywords with values are included in the standalone keyword record. Find(keywordType) looks for a keyword record which contains a keyword of the type in it. Since the keyword is blank, it does not find any keyword records. Using the keyword record type lets you find a keyword record which is configured to contain a keyword type, regardless of whether that keyword is currently present in the keyword record or not.
Hope this helps!
07-10-2016 04:52 AM
07-11-2016 10:02 AM
07-14-2016 05:35 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.