Change Value based on change of another field

govardhantv
Kilo Contributor

Hi All,

We have change table in that we have two fields ."ci "is reference field(cmdb_ci) and "type" is string with four values(standard,comprehensive,stable and delay)

,now we have a requirement that when ever type of ci is corporate then only then only in the "type "field we need to get the option "stable"other wise "type"field should populate only three dropdown values.

find_real_file.png

Warm Regards

Govardhan

1 ACCEPTED SOLUTION

india
Tera Guru

Hi,



Go to UI policy and select



condition: configuration item is corporate



in advance mode



run script this



if true


g_form.setValue('your field name','stable);


g_form.removeOption('your_field_name, 'value of   standard');//add choices as per requirement


g_form.removeOption('your_field_name, 'value of ,comprehensive'   )


g_form.removeOption('your_field_name, 'value of   delay')



if false


g_form.removeOption('your_field_name','value of stable');




value of choice get by right click on choice and click on Show Choice list.



Mark as:   LIKE/Correct/Helpful




View solution in original post

8 REPLIES 8

prajaktanaik
Giga Expert

Hi,



You can write onChange/onLoad client script and make use of removeOption method as explained in the below link:


http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#removeOption



Regards,


Prajakta



PS - Hit Like, Helpful or Correct Answer, if applicable.


i am new to java script ,and what i have tried hasn't worked can i have the code.


Hi,



Create an OnChange client script and give the field name as your ci field name. Write the below code:



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }



if(newValue != 'corporate'){


g_form.removeOption('field_name_for_type', 'value of stable');


}  


}



Write the same code in onLoad CS as well.



Let me know, if this helps.



Regards,


Prajakta



PS - Hit Like, Helpful or Correct Answer, if applicable.


Hi thank you for the reply ,


but my requirement is ,when ever "ci" is corporate then only i have see the value stable in the "type"field other wise i should not see