08-21-2019 08:32 AM
Hello All,
I'm trying to use the APIs to create a Unity Script to modify a Keyset. What I ultimately want to do is modify an autofill keyset and remove any records already placed into a repeating section.
Baby Steps first though.
I am following the example in the SDK for deleting a Keyset record, but the Keyset.Delete is always returning False, and I don't know why.
I am assuming it is because of a permission issue, because of this statement found in the SDK when talking about Keysets:
"The user must have rights to Create, Update and Delete a Keyset. There are no user specific rights associated with Retrieve."
I believe I have successfully retrieved the Keyset, as I can do a count on the keyset and get the correct number of keyset records. It's just that when I actually try to do the delete, False is always returned.
Can anyone tell me what I might be missing? Or even how to get more information other than just having the boolean set?
Here's pretty much what my code is. (Just changed names of ID's and such.) getString and putString I made just to make it easier to move data back and forth to the unity form.
Any help would be appreciated.
(I'm sure creating an Autofill Keyset script would be another alternative, and I can use that for retrieving database information, but I don't know how to get data from the repeating section of the unity form in the Autofill Keyset script.)
Thanks
==============================
// Skeleton generated by Hyland Unity Editor on 8/20/2019 1:26:10 PM
namespace MyIDCheck
{
using System;
using System.Text;
using Hyland.Unity;
using Hyland.Unity.CodeAnalysis;
using Hyland.Unity.UnityForm;
/// <summary>
/// Checks the Autofill Dataset and removes records already used within the repeating frame.
/// </summary>
public class MyIDCheck : Hyland.Unity.UnityForm.IUnityFormCustomActionEventScript
{
#region IUnityFormCustomActionEventScript
/// <summary>
/// Implementation of <see cref="IUnityFormCustomActionEventScript.OnCustomActionExecuteAction" />.
/// <seealso cref="IUnityFormCustomActionEventScript" />
/// </summary>
/// <param name="app"></param>
/// <param name="args"></param>
public void OnCustomActionExecuteAction(Hyland.Unity.Application app, Hyland.Unity.UnityForm.UnityFormCustomActionEventArgs args)
{
// Add Code Here
try {
var unityForm = args.FormInstance;
var unityFormModifier = unityForm.CreateUnityFormModifier();
var MyID = getString("MyID175", unityForm);
putString("MyIDCheck",MyID.ToString(),unityForm);
var keywordSetName = "ABCDE";
Keyset keyset = app.Core.AutoFillKeywordSets.Find(keywordSetName);
//
// https://sdk.onbase.com/unitySDK/html/f28dc57a-6800-443a-9216-b38f25723081.htm
//
// Create a form modifier object
Hyland.Unity.UnityForm.FormModifier formModifier = unityForm.CreateUnityFormModifier();
// Set your primary keyword based upon which keyset(s) you are looking for
Keyword primaryKeyword = keyset.PrimaryKeywordType.CreateKeyword(MyID.ToString());
// Get record(s); there could be more than one depending on how the keyset is configured
KeysetDataList keysetDatas = keyset.GetKeysetData(primaryKeyword);
//var keysetDatasCount = keysetDatas.Count;
//putString("ViolationCount",keysetDatasCount.ToString(),unityForm);
// We will delete the first (and potentially only) matching record
KeysetData keysetData = keysetDatas[0];
bool returnValue = false;
// returnValue will be set to reflect whether the operation completed successfully
returnValue = keyset.Delete(keysetData);
putString("DeleteResult",returnValue.ToString(),unityForm);
var keysetDatasCount = keysetDatas.Count;
putString("DeleteCount",keysetDatasCount.ToString(),unityForm);
} catch (Exception ex) {
app.Diagnostics.Write("Error : {0}", ex);
//Console.WriteLine("Error : {0}", ex);
}
}
static string getString(string fieldName, Hyland.Unity.UnityForm.Form unityForm)
{
try {
return unityForm.AllFields.ValueFields.Find(fieldName).AlphaNumericValue;
} catch (Exception) {
return "";
}
}
static void putString(string fieldName, string inString, Hyland.Unity.UnityForm.Form unityForm)
{
try {
// Updating a Unity Form
// https://sdk.onbase.com/unitySDK/html/d9de8752-36a3-4136-ad56-1a58d97e4a8a.htm
// Create a form modifier object
Hyland.Unity.UnityForm.FormModifier formModifier = unityForm.CreateUnityFormModifier();
// Ensure the form is configured to allow updates to this field
Hyland.Unity.UnityForm.FieldDefinition fieldDefinition = unityForm.FormTemplate.AllFieldDefinitions.Find(fieldName);
if (unityForm.FormTemplate.IsFieldEditable(fieldDefinition)) { // Set the new field value and apply the change
formModifier.SetFieldValue(fieldName, inString);
formModifier.ApplyChanges();
//Console.WriteLine(string.Format("\nForm Field (txtNewFirstName) updated to {0}.",
//unityForm.AllFields.ValueFields.Find(fieldName).Value));
}
} catch (Exception) {
unityForm.AllFields.ValueFields.Find(fieldName).Equals("");
}
}
#endregion
}
}
08-21-2019 08:49 AM
Hi Michael --
This seems like an issue it would be worth creating a Support Issue for -- you mind if I contact you by email about it?
08-21-2019 08:48 AM
Hello All,
I'm trying to use the APIs to create a Unity Script to modify a Keyset. What I ultimately want to do is modify an autofill keyset and remove any records already placed into a repeating section.
Baby Steps first though.
I am following the example in the SDK for deleting a Keyset record, but the Keyset.Delete is always returning False, and I don't know why.
I am assuming it is because of a permission issue, because of this statement found in the SDK when talking about Keysets:
"The user must have rights to Create, Update and Delete a Keyset. There are no user specific rights associated with Retrieve."
I believe I have successfully retrieved the Keyset, as I can do a count on the keyset and get the correct number of keyset records. It's just that when I actually try to do the delete, False is always returned.
Can anyone tell me what I might be missing? Or even how to get more information other than just having the boolean set?
Here's pretty much what my code is. (Just changed names of ID's and such.) getString and putString I made just to make it easier to move data back and forth to the unity form.
Any help would be appreciated.
(I'm sure creating an Autofill Keyset script would be another alternative, and I can use that for retrieving database information, but I don't know how to get data from the repeating section of the unity form in the Autofill Keyset script.)
Thanks
==============================
// Skeleton generated by Hyland Unity Editor on 8/20/2019 1:26:10 PM
namespace MyIDCheck
{
using System;
using System.Text;
using Hyland.Unity;
using Hyland.Unity.CodeAnalysis;
using Hyland.Unity.UnityForm;
/// <summary>
/// Checks the Autofill Dataset and removes records already used within the repeating frame.
/// </summary>
public class MyIDCheck : Hyland.Unity.UnityForm.IUnityFormCustomActionEventScript
{
#region IUnityFormCustomActionEventScript
/// <summary>
/// Implementation of <see cref="IUnityFormCustomActionEventScript.OnCustomActionExecuteAction" />.
/// <seealso cref="IUnityFormCustomActionEventScript" />
/// </summary>
/// <param name="app"></param>
/// <param name="args"></param>
public void OnCustomActionExecuteAction(Hyland.Unity.Application app, Hyland.Unity.UnityForm.UnityFormCustomActionEventArgs args)
{
// Add Code Here
try {
var unityForm = args.FormInstance;
var unityFormModifier = unityForm.CreateUnityFormModifier();
var MyID = getString("MyID175", unityForm);
putString("MyIDCheck",MyID.ToString(),unityForm);
var keywordSetName = "ABCDE";
Keyset keyset = app.Core.AutoFillKeywordSets.Find(keywordSetName);
//
// https://sdk.onbase.com/unitySDK/html/f28dc57a-6800-443a-9216-b38f25723081.htm
//
// Create a form modifier object
Hyland.Unity.UnityForm.FormModifier formModifier = unityForm.CreateUnityFormModifier();
// Set your primary keyword based upon which keyset(s) you are looking for
Keyword primaryKeyword = keyset.PrimaryKeywordType.CreateKeyword(MyID.ToString());
// Get record(s); there could be more than one depending on how the keyset is configured
KeysetDataList keysetDatas = keyset.GetKeysetData(primaryKeyword);
//var keysetDatasCount = keysetDatas.Count;
//putString("ViolationCount",keysetDatasCount.ToString(),unityForm);
// We will delete the first (and potentially only) matching record
KeysetData keysetData = keysetDatas[0];
bool returnValue = false;
// returnValue will be set to reflect whether the operation completed successfully
returnValue = keyset.Delete(keysetData);
putString("DeleteResult",returnValue.ToString(),unityForm);
var keysetDatasCount = keysetDatas.Count;
putString("DeleteCount",keysetDatasCount.ToString(),unityForm);
} catch (Exception ex) {
app.Diagnostics.Write("Error : {0}", ex);
//Console.WriteLine("Error : {0}", ex);
}
}
static string getString(string fieldName, Hyland.Unity.UnityForm.Form unityForm)
{
try {
return unityForm.AllFields.ValueFields.Find(fieldName).AlphaNumericValue;
} catch (Exception) {
return "";
}
}
static void putString(string fieldName, string inString, Hyland.Unity.UnityForm.Form unityForm)
{
try {
// Updating a Unity Form
// https://sdk.onbase.com/unitySDK/html/d9de8752-36a3-4136-ad56-1a58d97e4a8a.htm
// Create a form modifier object
Hyland.Unity.UnityForm.FormModifier formModifier = unityForm.CreateUnityFormModifier();
// Ensure the form is configured to allow updates to this field
Hyland.Unity.UnityForm.FieldDefinition fieldDefinition = unityForm.FormTemplate.AllFieldDefinitions.Find(fieldName);
if (unityForm.FormTemplate.IsFieldEditable(fieldDefinition)) { // Set the new field value and apply the change
formModifier.SetFieldValue(fieldName, inString);
formModifier.ApplyChanges();
//Console.WriteLine(string.Format("\nForm Field (txtNewFirstName) updated to {0}.",
//unityForm.AllFields.ValueFields.Find(fieldName).Value));
}
} catch (Exception) {
unityForm.AllFields.ValueFields.Find(fieldName).Equals("");
}
}
#endregion
}
}
08-21-2019 08:49 AM
Hi Michael --
This seems like an issue it would be worth creating a Support Issue for -- you mind if I contact you by email about it?
08-21-2019 10:22 AM
Sure, go ahead! Any help would be appreciated. My luck, I've got one setting switched off that should be on...
08-22-2019 07:31 AM
function (id) { $http.post('/api/comment/create', { ParentItemId: id, Body: self.commentBody }).then(function (response) { location.href = location.pathname + '#Reply_' + response.data.Id; location.reload(); }); }
I don't know if there's a messaging system within HylandCommunity, haven't seen a way to contact you directly. So I'm checking with you through comments....
Is there an email/messaging service I can use to contact you?
Thanks
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.