Add/Remove values from a List collector based on Check box fields.

Nipan1
Tera Contributor

Hi, 

 

I have a requirement to populates(add) value in a list collector's value/ remove the value of the list collector field, based on 3 check box fields. 

 

I have tried Script include and onChange client script and also tried to modify through Reference qualifier of the list collector field. But nothing is working. 

 

Please suggest me a better way to achieve it.

 

Reference picture of my requirement: 

  • If the user choose Digital Engg app in the Application field, the check boxes will appear. 
  • Then if user checks any check box, it will add/remove the value in Application field. 

Nipan1_0-1725562681234.png

 

Thanks

 

1 ACCEPTED SOLUTION

Good job with the logs.  You were very close - just a misplaced } that was causing there to be no 'else' to the if (newValue == 'true').  Then you would have discovered that you want to use splice to remove an element from an array in this case, not slice which creates a new array with the removed elements.  Here's the working if block:

if (newValue == 'true') {
    if (appVal.indexOf(jira_sysid) === -1) {
        appVal.push(jira_sysid);
        alert('added: ' + jira_sysid);
    }
} else {
    var index = appVal.indexOf(jira_sysid);
    alert('index found at: ' + index);
    if (index != -1) {
        alert('removing');
	    appVal.splice(index, 1);
    } else {
        alert('value not found for removal!');
    }
}

 

View solution in original post

5 REPLIES 5

Great to hear.  You are welcome!