Removing a indexed parameter

Anyone know why this doesn’t work?? :frowning:

for (i = 0; i < teamNodes.length; i++) {
if (params.getValue(‘homeTeamsID’, i) == “x”) {
params.getParam(‘homeTeamsID’, i).remove();
};
};
There must be something wrong with [QUOTE]params.getParam(‘homeTeamsID’, i).remove(); since I managed to set the value to something else if I change it to params.setValue…

Hi Tobias.
One thing that might be impacting you is that the number of nodes you have will change after you call remove so you might be running into problems there…
A way to solve this would be to add a “break;” after you remove the param to exit your loop.

a b c d e f g h i params.myparam var elemCount = params.getElementCount('params.myparam'); for (var i = 0; i < elemCount; i++) { var param = params.getParam('params.myparam', i); if (param.getValue() == 'g') { param.remove(); break; } }

Another option would be to use params.setAllValues. This would work if you are trying to remove multiple values or don’t want to exit your loop until the end for some other reason:

var elemCount = params.getElementCount('params.myparam'); var newValues = []; for (var i = 0; i < elemCount; i++) { var paramValue = params.getValue('params.myparam', i); if (paramValue != 'e') { newValues.push(paramValue); } }

params.setAllValues(‘params.myparam’, newValues);

#DashBoard

I actually found another way to set my parameter values which gets me around the issue of removing items. But this is still useful, thank you!
#DashBoard