Need help of clear a list collector variable

Erica2
Tera Contributor

Hello,

Could someone please suggest on how to clear/empty a list collector variable after form loaded using catalog client script?   I'm familiar UI Policies, but needed to learn using client script. 

 

Thank you

 

9 REPLIES 9

Hi @Samaksh Wani 

 

Here is my list collector name:  approverList

Where do I need replace it in the code?

 

 

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Erica2 

Greetings!

Could you please elaborate your question. I believe When the form is loaded, the list collector would be empty. because no selection is made by user 

refer below thread if it helps your scenario;

https://www.servicenow.com/community/developer-forum/to-clear-list-collector-values-on-change-of-a-v...

please mark the answer as correct and helpful if helped.

Kind regards,

Ravi Chandra.

Hello @Ravi Chandra_K 

The list collector is currently uses for request approval.  Once selected values(approvers) have been sent, we would like to clear out the list so that user have an option to select additional approvers.

Harish Bainsla
Kilo Patron
Kilo Patron

var variableName = 'list_collector_var';
g_form.setValue(variableName, []);
g_form.addInfoMessage('List collector variable cleared.');

Hello @Harish Bainsla 

I tried the following code, but I have no luck of getting it to works:

 

function onLoad() {
    var variableName = 'approverList';
    g_form.setValue(variableName, []);
    g_form.addInfoMessage('List collector variable cleared.');
}