Friday, April 6, 2012

InfoPath Tips #5-Concatenating Repeating Fields, the other scenario

This is going be a summary of the thread I posted on the InfoPathDev site.

A lot of people have read this or similar article about concatenating a field that stored in a repeating group, that is one scenario of a repeating field, the other scenario is to have a repeating field inside a none repeating group.I experimented many formula with the eval() function, and the closest result had two issues:
1) the result had a leading delimiter, and a trailing delimiter too
2) when you remove a selection from the multiple-selection list, the textbox control storing the concatenated value will not be updated.

The reason behind the first issue was the XML content of the InfoPath form actually has a blank first entry.

Finally I found the reply Jimmy Rishe posted on this thread. His formula basically filtered out the blank entry, generating a ";XYZ;XYZ;XYZ;" string then removed the first character using substring:

substring(eval(eval(field1[. != ""], 'concat(";", .)'), ".."), 2)


What I still not sure is what Jimmy did to get around the second issue. He added a formula to set the default value of the control which bound to the field that accepts the concatenated string-considering the prior action already was assigning a value to the field and the textbox was bound the field etc.
Oh, well, as long as it works. We should just move on.

1 comment: