cancel
Showing results for 
Search instead for 
Did you mean: 
XenoIcon
Nintex Newbie

Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution

Hey there,

I have been trying to write multiple choice fields to a generated document and I just wanted to know if there was a clean way of using regular expression or any other recommended action to remove the square brackets and quotation marks?

I have attached what the output from the multiple choice option looks like in the document.

Nintex multiple choice issue.jpg

Labels: (2)
Tags (1)
Reply
8 Replies
burked
Nintex Employee
Nintex Employee

Re: Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution

The multiple choice action is going to function as a collection, so it will output the information in this format.  The quickest way to do this will be using a Regex Replace action. One note, you will need to create an empty text variable for the replacement text (go to variables, create variable and leave default value for this variable blank).  

 

From there you will configure the action like below:

CollectionRegex.png

The 'Input Text' will be the choice control. 

The pattern will be formatted like below:

(\[)|(\")|(\])

The replacement text will be the empty variable I created (named blank)

The 'Store Results in' will be a separate text variable that can then be used in your workflow. 

 

Here is the output from my log to instance details (showing pre-regex and post-regex):

ResultsRegex.png

 

 

View solution in original post

Reply
XenoIcon
Nintex Newbie

Re: Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution
Hey Burked,
This is perfect! Thank you for putting the time and effort into that detailed response.
Reply
ChetChudasamaTS
Nintex Newbie

Re: Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution

@burked 

 

Is there a way of doing this in Nintex Forms for Office 365 using replace and possibly adding a line break instead of the comma?

0 Kudos
Reply
burked
Nintex Employee
Nintex Employee

Re: Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution

Hi @ChetChudasamaTS ,

 

This is definitely possible.  I configured my form with a Choice Control (multiple-selection), provided the control with the name Multi Choice, along with a calculated value control:

 

O365FormReplace.png

 

I configured the calculated value control with the formula below (replace MULTI-SELECT_NAMED_CONTROL with the named control reference of your choice control):

 

replace(replace(MULTI-SELECT_NAMED_CONTROL, "(\[)|(\])", ""), ",", "<p>")

I also configured the calculated value control to resize at runtime so it will expand as we have more selections. It's configured like below: 

 

CalcValueConfig.png

 

When the user interacts with the form, it will look like this:

 

CalcReplaceRuntime.png

Reply
ChetChudasamaTS
Nintex Newbie

Re: Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution

Hi @burked,

 

Thanks for all your help so far, I got a further question regarding the formula please, Is there a way to only return the first value for the array?

 

I have a repeating table of destination cities and use the formula

replace(replace(parseLookup(CityField), "(\[)|(\])", ""), ",", "; ")

to return for example "London; New York; Geneva:

 

Now how do I get it to only return London in a separate calculated field - is there a way to replace everything after and including the first semicolon; so the output would be just London??

0 Kudos
Reply
DavidAD
Nintex Newbie

Re: Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution

@burked I must be doing something wrong somewhere. I've copied your solution precisely (or so I believe) but it's not working. In the Input text field, I have inserted the collection variable from the Start event. Then I've followed your instructions for the other fields. My Replacement text is a blank variable I created, called Reformatted selections. Then I'm storing results in another variable called Choices for email (because I want to include the selections in an email).

Based on my instance details, my problem seems to be in the Reformatted selections value: it remains blank.

Here, the Choices made are the selections from the multiple choice field, Reformatted is the reformatted selections variable, and Choices is the Choices for email variable.

DavidAD_0-1612199215709.png

The only difference I see between my action and the one in the solution is that the Input text value in the solution is showing with a Collection icon while mine just has the usual "X" icon. But I thought this might just be the result of a change made in NWC since the solution was posted nearly two years ago. If not, I don't see where I would get that Collection variable.

Anyway, any help (from anyone) is appreciated!

0 Kudos
Reply
burked
Nintex Employee
Nintex Employee

Re: Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution

Hi David,

 

The 'Store Results in' option is writing the Regex result back formatted as a collection, so you have two options.

 

1) You can use the 'Store First Result in' drop down and put your text variable there. This should get the value you're looking for.

2) You can use a 'Get Item From Collection' action to retrieve the results. You shouldn't need to do this though, as option one should be clean.

 

As far as the look of the variable, it has changed a bit on the icons over the last 2 years. With Start Forms being treated as objects now, the variables have gotten an update for the look and feel.

 

Hope this helps!

Reply
DavidAD
Nintex Newbie

Re: Way to remove the square brackets and quotation marks from a multiple choice list?

Jump to solution

@burked Thanks for such a quick response! Yep, I did as you suggested and that worked a treat (as the Brits say). Much obliged!

Reply