Hiding Catalog Variables AFTER submitted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2010 08:44 AM
HELP!!
I'm having trouble getting the show/hide functionality to work on catalog variables after the request has been submitted. THe show/hide works great when the form is being filled out but is lost after it is submitted. I've tried using the UI policy in the sc_req_item table and I've tried using client scripts during onload for the same table, bot with no success.
Any ideas??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2010 09:16 AM
You can hide item variables on the requested items with an onload client script on the sc_req_item table using the following:
g_form.setDisplay('variables.variablename', false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2010 01:49 PM
I did that with no result. Here is the code. It tests for a document type and displays the fields if it is true, else, hide the variables. The variable are not hiding. Maybe I'm just not seeing something.
function onLoad() {
if (g_form.getValue('variables.DocumentType') == '9677afed0a0a1614019a1d659ad770a4'){
g_form.setDisplay('variables.SPA', true);
g_form.setDisplay('variables.SPA_contract_term', true);
g_form.setMandatory('variables.SPA_contract_term', true);
g_form.setDisplay('variables.SPA_territory', true);
g_form.setMandatory('variables.SPA_territory', true);
g_form.setDisplay('variables.SPA_approval', true);
g_form.setMandatory('variables.SPA_approval', true);
g_form.setDisplay('variables.SPA_existing', true);
g_form.setMandatory('variables.SPA_existing', true);
g_form.setDisplay('variables.SPA_direct_lsp', true);
g_form.setMandatory('variables.SPA_direct_lsp', true);
g_form.setDisplay('variables.SPA_software', true);
g_form.setMandatory('variables.SPA_software', true);
g_form.setDisplay('variables.SPA_maint', true);
g_form.setMandatory('variables.SPA_maint', true);
g_form.setDisplay('variables.SPA_license', true);
g_form.setMandatory('variables.SPA_license', true);
} else {
g_form.setDisplay('variables.SPA', false);
g_form.setDisplay('variables.SPA_contract_term', false);
g_form.setMandatory('variables.SPA_contract_term', false);
g_form.setDisplay('variables.SPA_territory', false);
g_form.setMandatory('variables.SPA_territory', false);
g_form.setDisplay('variables.SPA_approval', false);
g_form.setMandatory('variables.SPA_approval', false);
g_form.setDisplay('variables.SPA_existing', false);
g_form.setMandatory('variables.SPA_existing', false);
g_form.setDisplay('variables.SPA_direct_lsp', false);
g_form.setMandatory('variables.SPA_direct_lsp', false);
g_form.setDisplay('variables.SPA_software', false);
g_form.setMandatory('variables.SPA_software', false);
g_form.setDisplay('variables.SPA_maint', false);
g_form.setMandatory('variables.SPA_maint', false);
g_form.setDisplay('variables.SPA_license', false);
g_form.setMandatory('variables.SPA_license', false);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2010 02:03 PM
It looks ok to me. I went into demo.service-now.com and added a client script called Make Mandatory that makes a variable mandatory on the Development Laptop RITM0010040, so you can reference that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2015 03:26 AM
May be this will help.
When setting display for fields false, first set their mandatory attribute to be false.
for example (from your code):
g_form.setDisplay('variables.SPA_contract_term', false);
g_form.setMandatory('variables.SPA_contract_term', false);
g_form.setDisplay('variables.SPA_territory', false);
g_form.setMandatory('variables.SPA_territory', false);
instead use
g_form.setMandatory('variables.SPA_contract_term', false);
g_form.setDisplay('variables.SPA_contract_term', false);
g_form.setMandatory('variables.SPA_territory', false);
g_form.setDisplay('variables.SPA_territory', false);