Client Script to get ALL Catalog Variable values

ljschwaberow
Giga Expert

I am looking for a some coding help...as this is not my strong suit. I am using a Catalog Item to display different System Access variables in   check box variables. We are building templates of what should be set to true for each employee based on their position. Those defaulted 'true' check boxes we are wanting to highlight. I've been able to do all of this so far by hard coding:

g_form.setValue('variable_name'), true;

g_form.getControl('variable_name;).parentNode.style.backgroundColor = 'LightBlue';

I would rather not hard code each variable name to highlight when the variable is 'true'. Could anyone help me with how to reference all the variables, see which ones are true and then highlight those? Is this even possible or is hard coding the only way to go?

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

This would work now in Fuji ..



jQuery('input[type=checkbox].cat_item_option:checked').each(function(){


(jQuery(this).parent().parent().css( "background-color", "LightBlue"));


}


);



But future upgrades , I am not sure


View solution in original post

6 REPLIES 6

ohhgr
Kilo Sage
Kilo Sage

Hi Lindsey,



You could modify the scripts provided in this great article http://www.servicenowguru.com/scripting/business-rules-scripting/hide-empty-variables-standard-form/



Rather than checking for empty variables you could check the ones that you need and later in the client script you could change the back-ground color for these variables.



Hope that helps.


Mandar


Hi Mandar,



Thanks for your reply! I have used this business rule and client-script to hide empty variables on other records. I did consider this at first but where would this business rule sit, on the Catalog Item table? The highlighting will take place on the Catalog Item before it's passed to any kind of record.


Kalaiarasan Pus
Giga Sage

This would work now in Fuji ..



jQuery('input[type=checkbox].cat_item_option:checked').each(function(){


(jQuery(this).parent().parent().css( "background-color", "LightBlue"));


}


);



But future upgrades , I am not sure


This worked great for the check boxes. I'm also wanting to do this with the select boxes I have on the form if the values is not 'standard_choice'. Would it be jQuery('input[type=selectbox].cat_item_option.value:not sure what to put here for does not equal 'standard_choice'').each(function(){