Have you ever wondered why cascading datasets in Unity Forms are still done at the keyword type letter in OnBase Config, or in Unity form datasets? There is a way to cascade datasets that is explained in the sdk using a external database, but what I will show you is a way to give Users access to data via WorkView and develop a Unity script to access it.
You want to use WorkView: "using workview = Hyland.Unity.WorkView;"
Snippet
// Get keyword types
string keywordValueParent= "";
KeywordType keywordValueParentKeyType = application.Core.KeywordTypes.Find( "keywordTypeParent" );
KeywordRecord keywordValueParentRecord = arguments.SearchParameters.RelatedKeywordRecords.Find( keywordValueParentKeyType );
Keyword keywordValueParentKey = (keywordValueParentRecord != null) ? keywordValueParentRecord.Keywords.Find( keywordValueParentKeyType ) : null;
keywordValueParent = keywordValueParentKey.Value.ToString().Trim();
//run filter to get attribute values
string WVFilterName = "WV Filter all parent and child values";
//get workview objects for Training Review Log
workview.Application workViewApp = application.WorkView.Applications.Find("WV Application Name");
//get the wv filter
workview.Filter filter = workViewApp.Filters.Find(WVFilterName);
//Create a FilterQuery object
workview.FilterQuery filterQuery = filter.CreateFilterQuery();
filterQuery.AddConstraint("ParentValue", workview.Operator.Equal, keywordValueParent);
//Exec the filterQuery
workview.FilterQueryResultItemList results = filterQuery.Execute(100);
//Iterate thru results
foreach (workview.FilterQueryResultItem result in results)
{
//get the column values
workview.FilterColumnValue ReasonCode = result.GetFilterColumnValue("ChildValue");
arguments.Results.AddKeyword( arguments.KeywordType.CreateKeyword(
ChildValue.Value.ToString() ) );
}
Components:
WorkView
An application, class, and two attributes with data: the first keyword drop down value and the corresponding child (cascaded) values.DocType
A doc type with two keywords, the initial keyword type and the child keyword type.Keyword Type
The child keyword type will be set to run an "External" Unity script. The script will be set to "Send existing Keyord values form Unity Forms." Will be execute every time the parent value changes. The Unity script will return the "results" to the keyword select box on the form (based on the parent value selected).Unity Script
The class of the script will extend "Hyland.Unity.IExternalKeywordDataSetScript".You want to use WorkView: "using workview = Hyland.Unity.WorkView;"
Snippet
// Get keyword types
string keywordValueParent= "";
KeywordType keywordValueParentKeyType = application.Core.KeywordTypes.Find( "keywordTypeParent" );
KeywordRecord keywordValueParentRecord = arguments.SearchParameters.RelatedKeywordRecords.Find( keywordValueParentKeyType );
Keyword keywordValueParentKey = (keywordValueParentRecord != null) ? keywordValueParentRecord.Keywords.Find( keywordValueParentKeyType ) : null;
keywordValueParent = keywordValueParentKey.Value.ToString().Trim();
//run filter to get attribute values
string WVFilterName = "WV Filter all parent and child values";
//get workview objects for Training Review Log
workview.Application workViewApp = application.WorkView.Applications.Find("WV Application Name");
//get the wv filter
workview.Filter filter = workViewApp.Filters.Find(WVFilterName);
//Create a FilterQuery object
workview.FilterQuery filterQuery = filter.CreateFilterQuery();
filterQuery.AddConstraint("ParentValue", workview.Operator.Equal, keywordValueParent);
//Exec the filterQuery
workview.FilterQueryResultItemList results = filterQuery.Execute(100);
//Iterate thru results
foreach (workview.FilterQueryResultItem result in results)
{
//get the column values
workview.FilterColumnValue ReasonCode = result.GetFilterColumnValue("ChildValue");
arguments.Results.AddKeyword( arguments.KeywordType.CreateKeyword(
ChildValue.Value.ToString() ) );
}
No comments:
Post a Comment