Spaces not appearing in InfoPath 2010 XPath Concat RRS feed

  • Question

  • I have an InfoPath form that users are submitting information to a linked SharePoint list.  Within this form, I have a number of Check boxes that the users can select from to identify specific areas that are impacted by the request.  Within a separate Text field, I have an XPath formula that concatenates the check boxes along with potential commas and spaces to help separate out the results.  The problem I have is that in the substrings of ", ", the space is disappearing from the final results displayed in the text field.  I have tried a few different options, but the below formula is the one that works best for my needs but it still doesn't include the space after a comma:

    concat(chkbx1, substring(", ", 1, string-length(chkbx1) * string-length(chkbx2) > 0), chkbx2, substring(", ", 1, string-length(concat(chkbx1, chkbx2)) * string-length(chkbx3) > 0), chkbx3)

    To give a little explanation of the above formula, basically each check box returns a specific string of text if the check box is checked.  If it is not checked, then the text value returned is simply "".  Each of the substring functions check the length of the previous check boxes and multiplies that by the current check box and if it is equal to 0 (basically no previous check boxes and the current check box have been checked) then don't display anything.  If the length of the check boxes values is greater than 0, then include the ", " in the concatenation between the previous and current check boxes.  So, with this said, say that Check Boxes 1 and 3 have been checked, the text output should be:  chkbx1, chkbx3  But, it is instead returning chkbx1,chkbx3  <--- no space after the comma

    Any suggestions on how to get my space to appear would be greatly appreciated.

    Wednesday, April 13, 2016 5:44 PM


  • Ok ... so I found a solution for this today.  Instead of using a very long drawn out formula that I previously provided and to have the field continuously recalculate itself, the solution was to use a much simpler one BUT to have the value of the field to show the concatenated fields set anytime one of the fields to be concatenated was changed.  Confused?  I know I was for a bit, but it does work!!  Here is the forum post that I found explaining what I was able to apply in using Rules and a much simpler formula:


    In case it isn't available anymore, here is the formula used:

    substring(eval(eval((Field1 | Field2 | Field3 | etc...)[. != ''], 'concat(", ", .)'), '..'), 3, 10000)

    For any fields included in the formula, you need to add a rule that on change that the field that contains the concatenated string is to have the value set to 'recalc'.  Then on the field where the concatenated string is to be placed, set a rule that when that field value is 'recalc', set the value to be the formula above.

    In the formula above, just add in your fields for the formula to reference, and as long as they have data in them, they will be concatenated and a comma&space will be placed between each.

    • Marked as answer by TheGopherKing Friday, April 15, 2016 7:56 PM
    Friday, April 15, 2016 7:56 PM