Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

onChange Catalog Client Script to Clear Values for Reference, Choice and List Collector Fields

chatsaurav19
Tera Contributor

Hi All,

 

I need to remove values from two reference fields, one choice field and one List Collector field based on a choice field selection.

 

Type of Request : Choice List ( On selection of this field, the below field values needs to be cleared )

 

Knowledge Base : Reference

Categories : Reference

Role: Choice

Manage Acess: List Collector

 

chatsaurav19_0-1694670932241.png

 

 

I tried using 'OnChange' Catalog Client Script but it isn't working:::

 

function onChange(control, oldValue, newValue, isLoading) {
// if (isLoading || newValue == '') {
// return;
// }

//Type appropriate comment here, and begin script below
if (isLoading) {
return;
}
if (newValue == "") {
g_form.clearValue('knowledge_base_kb');
g_form.clearValue('categories_kb');
g_form.clearValue('role_kb');
g_form.clearValue('manage_acess_kb');
}
}

 

Can someone help me in this?

 

Regards,

Saurabh Chatterjee

 

1 ACCEPTED SOLUTION

Can you check if Ui type is selected ALL & Variable name

 

VishalBirajdar7_1-1694672092615.png

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

8 REPLIES 8

Hi @Vishal Birajdar ,

 

Yes I had to select 'All' and it worked.

 

Hi @Ankur Bawiskar 

 

Thank you for your help as well

 

Regards,

Saurabh

@chatsaurav19 

selecting All should have been the 1st thing when you create the client script

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

Indeed..!! I have also done same mistakes in initial phase.

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hi @Ankur Bawiskar 

 

Noted!

 

Regards,

Saurabh