Tommy Valand posted on his blog yesterday and on the Notes 8.5 forum today a bug with multi-value fields. Basically save switches the output between a multi-value field and a semi-colon-separated string.
Coincidentally I was working on an XPages application today, with a keyword form, for which I needed a multi-value field. Not surprisingly, I got exactly the same output.
I don’t know if it’s something that’s slipped into 8.5.1 or something that’s been there since 8.5.0, but considering that it’s consistent and unlikely to be resolved within the timescales required by my app, I set about trying to get a workaround. And so here it is.
For your multi-value field(s), add this code to the querySaveDocument event of the DominoDocument data element. If you unsure where that is, you’ll need to go into All Properties, just here:
Enter this code, changing the component name and field name:
The first line puts the code into a variable called val. The second line explodes the value using the separator “;”. The third line calls currentDocument.replaceItemValue to set the value – @SetField doesn’t work and it also refreshes the page. You’ll notice we’re doing an @ReplaceSubstring. This is because the value, after first save, is (I think) an array. Basically, without this you get:
Another caveat. This will not work if a new line separator. @Explode(…, @NewLine) splits the string at carriage returns and the letter “t” in Internet Explorer. I haven’t tested in other browsers, so cannot confirm or deny the same behaviour for those.
Leave your multi-value separator as “;” in the text field or textarea (I’m using the latter). This will ensure you get a semi-colon-separated list when you edit the document rather than a comma-separated list.
The code is attached.
After a night’s sleep, a couple of additional thoughts.
1) In theory, this should have no negative impacts once multi-value fields do convert their input consistently.
2) I haven’t investigated, but another option might be to add similar code on the Input Translation of the form, and set computeWithForm to onsave.