I have a form with a collection on it of 4 fields. I allow up to a maximum of up to 4 individual collections on the form. I am passing the form to a workflow where I "Retrieve Business Process Variables" for the purpose of passing that data to a "Fill out PDF Form" activity.
After entering the values on the form and letting the workflow create the PDF, the values populated on the PDF 'start over' (See attached). In the Name field (On the PDF) there is a place for a name up to 4 times. If I only enter in 3 names on the LF form, the fourth name is still added to the PDF form and starts over as 1.
In the above instance, I only added "Anthony 1", "Anthony 2" and "Anthony 3". Here is a screen of my workflow:
In the "Fill Out PDF fields" activity I am using this for each of the fields on the PDF %(RetrieveBusinessProcessVariables_Defendants\DefendantName#[1]#), incrementing the index for each of the fields. If the person filling out the LF form only enters 1 name I want only one name copied to the PDF. I am not sure why the index restarts OR why the value gets written to the last index.
****EDIT I figured this out and this is much simpler than my original attempt. If I bring in the collection of fields from the "retrieve business..." activity and use the TABLE tab in the "Fill PDF..." activity there's no need to loop through tokens, or worry about them in any way. All you need to do is reference the fields in the PDF through regex and assign the values to the collection (no need for indexes).