remove selected list collector values

PK14
Kilo Guru

Hi SN Expert,

On selection of a field (select box), list collector data gets populated. But the right bucket data doesn't get cleared. 
I am using the below script which works fine but doesn't support on JavaScript browser console (error: There is a JavaScript error in your browser console).

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === oldValue) {
        return;
    }
  var varName = 'access_level'; //(List collector backend name)
    var rightBucket = gel(varName + '_select_1');
    var selectedOptions = rightBucket.options;
    var i = (selectedOptions.length - 1);
    for (i; i >= 0; i--) {
        var value = selectedOptions[i].value;
        rightBucket.remove(value);
    }
}



4 REPLIES 4

Community Alums
Not applicable

Hi @PK14 ,

Can you verify the isolate script is check?

Hi @Community Alums 

Isolated script is checked. Still doesn't work

Ankur Bawiskar
Tera Patron
Tera Patron

@PK14 

why are you using DOM manipulation? It's not recommended.

The DOM won't work in portal.

Nowadays many customers are using portal so you better handle it for that as well.

you can handle via onSubmit catalog client script

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@PK14 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader