Need help in client script

nameisnani
Mega Sage

Hi Team 

 

can any one please help me , in this request 

Based on the type of request ,  Infrasturure request should populate .

 

can any one please provide me script for this .

 

nameisnani_1-1721618990080.png

 

nameisnani_0-1721618948635.png

 

12 REPLIES 12

nameisnani
Mega Sage

It's bit confused , could you please provide script 

Hi @nameisnani ServiceNow is all about Best Practice. I would suggest you to always prefer OOTB solution if possible. I'm sure you will get more complex requirement than this in future. So confusion cannot be the reason to not implementing the OOTB solution. 

Cheers!!! 

Arya123
Tera Expert

Hi @nameisnani ,

You can use Catalog OnChange Client Script

Select the type : Onchange

Select the Variable Name: type_of_request// use you backend value

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

 var type = g_form.getValue('type_of_request');
 if (type == 'mainframe')//use the backend value of the Knydrnl Mainframe
 {
    g_form.removeOption('infra','storage_backup');//replace with your backend vale of Infrastructure request and Storage & BackUp
 }
 else
 {
    g_form.addOption('infra','storage_backup','Storage & BackUp');
 }
   
}
//add g_form.removeOption and g_form.addOption for other Choice aslo


Community Alums
Not applicable

I think this a good template to follow. Although you don't need a variable for type. The "newValue" contains the value for type of request so it become redundant to call it twice. 

nameisnani
Mega Sage

@Arya123 

your script is not working 

nameisnani_0-1721624651135.png