UI Policies Applied to Yes/No Variables on INC Variable Editor

ljschwaberow
Giga Expert

I read through the following thread:UI policies on record producers should be applied on incident form variable editor and many others (even posted one Re: Applying UI Policies to Variable Editor, which ended up on a different issue all together) and am still struggling with this. Similar to the issue in 'UI Policies on record Producer...' I have UI Policies applied to my record producer and I do have a script in place that removes 'empty' variables on the Incident Variable Editor, however, most of my questions are 'Yes/No' with a default answer and thus they are not empty. I've tried writing a few Client Script similar to:

functon onLoad () {

if (variables.device_with_issue == 'my printer') {

                                                              g_form.setVisible(variables.lasercycle_number, false);

                                                              g_form.setVisible(variables.print_application, false);

                                                              g_form.setVisible(variables.print_application_name, false);

                                                              g_form.setVisible(variables.short_description, false);

                                                              g_form.setVisible(variables.u_does_this_issue_affect_more_, false);

                                                              g_form.setVisible(variables.u_who_is_affected_, false);

                                                              g_form.setVisible(variables.u_number_of_employees_affected, false);

                                                              g_form.setVisible(variables.u_are_you_able_to_work_around_, false);

But I'm discovering that 'variables.device_with_issue' isn't working. I tried 'producer.device_with_issue' and still nothing. Has anyone tried this sort of Client Script and had success?

Thanks,

Lindsey

1 ACCEPTED SOLUTION

manikorada
ServiceNow Employee
ServiceNow Employee

Lindsey,



There are syntax errors in your script and you need to do something like:


functon onLoad () {


if (g_form.getValue('variables.device_with_issue') == 'my printer') {


                                                              g_form.setVisible('variables.lasercycle_number', false);


                                                              g_form.setVisible('variables.print_application', false);


                                                              g_form.setVisible('variables.print_application_name', false);


                                                              g_form.setVisible('variables.short_description', false);


                                                              g_form.setVisible('variables.u_does_this_issue_affect_more_', false);


                                                              g_form.setVisible('variables.u_who_is_affected_', false);


                                                              g_form.setVisible('variables.u_number_of_employees_affected', false);


                                                              g_form.setVisible('variables.u_are_you_able_to_work_around_', false);


}


}


View solution in original post

4 REPLIES 4

manikorada
ServiceNow Employee
ServiceNow Employee

Lindsey,



There are syntax errors in your script and you need to do something like:


functon onLoad () {


if (g_form.getValue('variables.device_with_issue') == 'my printer') {


                                                              g_form.setVisible('variables.lasercycle_number', false);


                                                              g_form.setVisible('variables.print_application', false);


                                                              g_form.setVisible('variables.print_application_name', false);


                                                              g_form.setVisible('variables.short_description', false);


                                                              g_form.setVisible('variables.u_does_this_issue_affect_more_', false);


                                                              g_form.setVisible('variables.u_who_is_affected_', false);


                                                              g_form.setVisible('variables.u_number_of_employees_affected', false);


                                                              g_form.setVisible('variables.u_are_you_able_to_work_around_', false);


}


}


I had a feeling it was my scripting, I am still learning. This worked perfectly! One question I don't know if you or anyone can answer - After these fields are hidden, there is just white space in it's place. Is there a way to put something in the scripting to remove this white space? Here is an image of what it looks like:


find_real_file.pngfind_real_file.png


hi Lindsey,



instead of   g_form.setVisible use   g_form.setDisplay('field name', false)


then it wont show the missing white space


-Anurag


Thank you!