You are viewing limited content. For full access, please sign in.

Question

Question

Multiple Field Values in Repository

asked on June 26, 2017 Show version history

Hello,

 

I'm working on a form that takes values from 2 checkboxes. These checkboxes belong to the same question; kind of a "Check all that apply" format. So, since you can check the 2 checkboxes, when the values are saved in the Repository-->Field, the values are separated by a comma (see screenshot below).

I was wondering if they can be grouped into individual Fields, one below the other, without the use of Workflow.

Would it be better in this case to add the question responses separately, and just differentiate them by a Yes/No value? 

What do you think?

RepositoryFields.png
0 0

Answer

SELECTED ANSWER
replied on June 26, 2017

If you're talking about something like a field with multiple values (where they are all under the same "Request Type" header but have their own fields) then the only way I know of to accomplish that is by using the column values of a table.

If you create a table element, you use a column as the value of a multi-value metadata field and when saving to the repository it will automatically add each row as a separate entry. You could utilize this for your current need by using JavaScript:

  1. On click (checkbox)
    • Iterate through each "checked" box 
    • Populate a row of the hidden table with the values

You wouldn't need the table to be dynamic because it should ignore anything that doesn't have any values. If you want to avoid JavaScript, you could pull this kind of thing off with Functions that reference the ROW() value to determine which checkbox to evaluate, and then use the true/false of the checkbox to populate the value into that row/cell.

However, this seems like a good case for a feature request, unless I'm missing something in the existing functionality. There is an option to include the "list of all checked" but there should be an option to split those into separate rows if the field allows multiple values. 

1 0

Replies

replied on June 27, 2017 Show version history

Jason, that's exactly what I was looking for. I created the table with two fixed fields and used Javascript to pass the value for each checkbox. Then I had to go back to the Template and check the checkbox for "Multiple", which I hadn't done. Tried it and it worked. Then I was wondering if it would work without the Table, and only the "Multiple" checkbox on the Template checked, and you are right, it did not work. So that would be a good feature request. 

I guess with a little more JavaScript I can remove the unwanted underscores too.

Thanks again Jason, that did the trick.

Thanks,

Raul

HiddenTable.png
RepositoryFields2.png
0 0
replied on June 27, 2017 Show version history

To get rid of the underscores you can add .replace to the end of the line where you retrieve the value or when you insert the value into the table.

YourValue.replace("_"," ");

EDIT: Incomplete, see the following message for the correct code.

0 0
replied on June 27, 2017 Show version history

MMM. For some reason it only replaced the first underscore. The line below worked though.

var checkbox = $('#somefield').val();
var checkbox_noUnderscore = checkbox.replace(/_/g, ' '); //remove underscores

 

1 0
replied on June 27, 2017 Show version history

My mistake, you're revision is the correct way to replace all occurrences. The version I posted only replaces the first instance of the match (always seem to forget that).

You can also try adding the .replace you wrote to the end of the .val() and do everything in one step. JQuery usually doesn't mind stacking method calls.

var checkbox = $('#somefield').val().replace(/_/g, ' ');

Just depends on whether or not you needed the unaltered version for anything.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.