cancel
Showing results for 
Search instead for 
Did you mean: 

Using Unity API to set a field within a repeater

Taylor_Betsinge
Champ in-the-making
Champ in-the-making

Hi everyone,

I have a Unity API that I want to fill in fields in a repeating section on a unity form. The API will select radio buttons within the repeating section.  For instance the value of 1 is "Yes" and the value of 2 is "No". For some reason it works fine with one of the radio buttons but does not work for any other radio buttons.

Hyland.Unity.UnityForm.Form form2 = doc.UnityForm;
Hyland.Unity.UnityForm.FormModifier formMod = form2.CreateUnityFormModifier();
RepeaterDefinition repeaterDef = form2.FormTemplate.AllFieldDefinitions.RepeaterDefinitions.Find("repeatingsection111");

EditableRepeaterItem erd = repeaterDef.CreateEditableRepeaterItem();

erd.SetFieldValue("radiobuttongroup488", "2");
erd.SetFieldValue("radiobuttongroup150", "1");

formMod.AddRepeaterItem(erd);
formMod.ApplyChanges();

 

radiobuttongroup488 has "No" selected just fine but for radiobuttongroup150 nothing is selected when it should have "Yes" selected. There are no errors or exceptions, the  code completes with no issue, its just not doing what is meant to be done.

Any and all advice is greatly appreciated! 

1 ACCEPTED ANSWER

Adam_Kuhn
Star Collaborator
Star Collaborator

Using the following code, I was able to set the values of all of the radio button groups.

var uftemp = app.Core.UnityFormTemplates.Find("RadioButtonTest");
StoreNewUnityFormProperties uFormProps = app.Core.Storage.CreateStoreNewUnityFormProperties(uftemp);
uFormProps.AddKeyword("Description", "Radio Button Test");
RepeaterDefinition repdef = uftemp.AllFieldDefinitions.RepeaterDefinitions.Find("repeater");
EditableRepeaterItem eri1 = repdef.CreateEditableRepeaterItem();
eri1.SetFieldValue("rbg1", "1");
eri1.SetFieldValue("rbg2", "0");
eri1.SetFieldValue("rbg3", "1");
eri1.SetFieldValue("textbox", args.Document.Name);
uFormProps.AddRepeaterItem(eri1);
Document newUnityForm = app.Core.Storage.StoreNewUnityForm(uFormProps);
Console.WriteLine(string.Format("Form Created: docid={0}.",newUnityForm.ID));

View answer in original post

5 REPLIES 5

Adam_Kuhn
Star Collaborator
Star Collaborator

Using the following code, I was able to set the values of all of the radio button groups.

var uftemp = app.Core.UnityFormTemplates.Find("RadioButtonTest");
StoreNewUnityFormProperties uFormProps = app.Core.Storage.CreateStoreNewUnityFormProperties(uftemp);
uFormProps.AddKeyword("Description", "Radio Button Test");
RepeaterDefinition repdef = uftemp.AllFieldDefinitions.RepeaterDefinitions.Find("repeater");
EditableRepeaterItem eri1 = repdef.CreateEditableRepeaterItem();
eri1.SetFieldValue("rbg1", "1");
eri1.SetFieldValue("rbg2", "0");
eri1.SetFieldValue("rbg3", "1");
eri1.SetFieldValue("textbox", args.Document.Name);
uFormProps.AddRepeaterItem(eri1);
Document newUnityForm = app.Core.Storage.StoreNewUnityForm(uFormProps);
Console.WriteLine(string.Format("Form Created: docid={0}.",newUnityForm.ID));

Getting started

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.