Skip to main content

Hi, I have a form with a repeating section with a single data lookup field (user's select one course from a list fed by a data source). My intention is to combine all of the requested courses into a single variable. To do that, I do a loop for each for the repeating section and in each loop I append that iteration's value to a variable. The intended result is a variable that would be Course 1, Course 2, Course 3, etc. However when I test my workflow, the variable has a bunch of extra markup (see below for example). How to I get rid of that?

 

 {"tf_ac8c64c171f545ed8faa1e7febeb8035_scheduled_course_title_copy_m1m33dtge":"Read, Lang and Learn 8"}, {"tf_ac8c64c171f545ed8faa1e7febeb8035_scheduled_course_title_copy_m1m33dtge":"Calculus AB"}, {"tf_ac8c64c171f545ed8faa1e7febeb8035_scheduled_course_title_copy_m1m33dtge":"English 100"}

Another route you can go is to create a text variable in the form and write the Course values selected from the repeating section into the variable. Then use the workflow to update the list item with the value in the form variable. Here is how to do this:



 





  1. Open the form and create a form variable with these settings:



    1. Name = txtCourses (or name it whatever you like)


    2. Type = Text


    3. Value = convertToString(Form.Select Course RS.Course)



      • Select Course RS is the name of the repeating section.


      • Course is a "Choice -single" control inside the repeating section.


      • You will need to use the convertToString function in the formula for the variable to convert the collection to a string.






    4. You can display the form variable inside a Label control to view the results as you select Courses.


    5. You could also use a regular expression to add a space after a comma in the text string.






  2. Add and configure an "Update items" action in the workflow.



    1. Add the Field in your list to update.


    2. Insert the form variable (txtCourses) to the field you want to update.


    3. Make sure you configure the Conditions to only update the one item (and not all the items).











Thanks, could you elaborate on using regex to add a space?

I was initially thinking of using a "Apply a regular expression" action in the workflow to replace "comma" in the string with a "comma space".



 



But this can be done in the form using the Replace function. Just update the formula in the form variable to this formula below:



 



replace(convertToString([Form].[Select Course RS].[Course]),",",", ")



 


Got it, thanks!

Reply