change a hidden value from true to false in Catalog Client Scripts onSubmit

Rui Zhao
Tera Contributor

Hello,

 

I am new to servicnow. I create a catalogue request,  in Catalog Client Scripts, I have onLoad scripts like this

function onLoad() {
//Type appropriate comment here, and begin script below
  g_form.setVisible("charge_back", false);
}

to set this variable to be hidden on the form,

 

but when the form submitted, I want to change this hidden variable to be saw on RITM

so I add onSubmit scripts in Catalog Client Scripts, like this

function onSubmit() {
//Type appropriate comment here, and begin script below
  g_form.setVisible("charge_back", true);
}

but this onSubmit script didn't work, the variable didn't show up in RITM.

 

Anyone can help? Thank you very much

1 ACCEPTED SOLUTION

Ethan Davies
Mega Sage
Mega Sage

Hey Rui,

 

You dont need to create an onSubmit Catalog Client Script. Instead, edit the existing onLoad client script that you have so that it only displays on the Catalog Item View, which means once it is submitted the code to hide 'charge_back' will not run.

 

EthanDavies_0-1680568236205.png

 

 

View solution in original post

2 REPLIES 2

Ethan Davies
Mega Sage
Mega Sage

Hey Rui,

 

You dont need to create an onSubmit Catalog Client Script. Instead, edit the existing onLoad client script that you have so that it only displays on the Catalog Item View, which means once it is submitted the code to hide 'charge_back' will not run.

 

EthanDavies_0-1680568236205.png

 

 

Rui Zhao
Tera Contributor

Hi Ethan,

 

Thank you very much. it works!