cancel
Showing results for 
Search instead for 
Did you mean: 

Copy repeater from one form to another

David_Chatterto
Star Collaborator
Star Collaborator

Hi,

 

I'm trying to copy all the values in a repeater from a previous form to a new form. Can someone advise if I'm on the right track?

 

Rendition rendition = document.DefaultRenditionOfLatestRevision;// Loop thru the repeater on the previous formforeach (RepeaterItem repeaterItem in rendition.UnityForm.AllFields.RepeaterFields.Find("internaltraining").RepeaterItems){	RepeaterItem repeaterItem2 = args.FormInstance.AllFields.RepeaterFields.Find("internaltraining").RepeaterItems;	EditableRepeaterItem editableRepeaterItem = repeaterItem2.CreateEditableRepeaterItem();
1 ACCEPTED ANSWER

Stefan_Sulea
Star Contributor
Star Contributor

Hi David, 

It's been a long time but this is what I used to add a single value, it's coming from the SDK examples. In your case it looks you are on the right track, you just need to add the rest of the stuff (create a form modifier, then in the loop SetFieldValue and AddRepeaterItem), and at the end commit the changes with ApplyChanges.

Hyland.Unity.UnityForm.FormModifier formModifier = args.Document.UnityForm.CreateUnityFormModifier();				// Find the repeater definition for the repeater section we want to add a row toRepeaterDefinition contactRepeaterDefinition = args.Document.UnityForm.FormTemplate.AllFieldDefinitions.RepeaterDefinitions.Find(REPEATING_SECTION);// Create a repeater item ( a virtual new row)  EditableRepeaterItem repeaterItem1 = ContactRepeaterDefinition.CreateEditableRepeaterItem();// set the fields in the new row (repeater item)repeaterItem1.SetFieldValue(COMMENT_FIELD, comment);//add the item we created to the repeating sectionformModifier.AddRepeaterItem(repeaterItem1);				//commit changes to the form modifierformModifier.ApplyChanges();

View answer in original post

1 REPLY 1

Stefan_Sulea
Star Contributor
Star Contributor

Hi David, 

It's been a long time but this is what I used to add a single value, it's coming from the SDK examples. In your case it looks you are on the right track, you just need to add the rest of the stuff (create a form modifier, then in the loop SetFieldValue and AddRepeaterItem), and at the end commit the changes with ApplyChanges.

Hyland.Unity.UnityForm.FormModifier formModifier = args.Document.UnityForm.CreateUnityFormModifier();				// Find the repeater definition for the repeater section we want to add a row toRepeaterDefinition contactRepeaterDefinition = args.Document.UnityForm.FormTemplate.AllFieldDefinitions.RepeaterDefinitions.Find(REPEATING_SECTION);// Create a repeater item ( a virtual new row)  EditableRepeaterItem repeaterItem1 = ContactRepeaterDefinition.CreateEditableRepeaterItem();// set the fields in the new row (repeater item)repeaterItem1.SetFieldValue(COMMENT_FIELD, comment);//add the item we created to the repeating sectionformModifier.AddRepeaterItem(repeaterItem1);				//commit changes to the form modifierformModifier.ApplyChanges();