- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2014 01:26 PM
Hi everyone,
I'm having a bit of a hard time trying to sort out how to hide a set of variables within a Change Request and potentially its Tasks as well. I have a Record Producer that's used to Create / Update Application CIs in our CMDB. We recently did an overhaul of the form, and in order to make the form look nice in terms of display, the developer had put in four Single-Line Text variables called "Spaceholder." On the form itself, there is no issue as the Catalog UI Policy hides them, but when the record and variables move into the Change Request, all of those variables are visible.
My first reaction was to put through an onLoad Client Script using g_form.setDisplay('variables.spaceholder',false); etc. on the change_request table but it does not seem to compute. My other thought was potentially running some sort of script within the workflow itself to start at the beginning of the workflow with the same sort of script idea.
Has anyone ever needed to try and do this? I've never had any experience doing this for Record Producers that start from sc_req_item and go to change_request - only regular Catalog Items where the one script seemed to work.
Any help or insight at all on this would be greatly appreciated. These variables will never need to be seen at any point.
Thank you,
Amandah
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2014 08:42 AM
The syntax for the or condition is not correct. Something like the following should work:
function onLoad() {
//Type appropriate comment here, and begin script below
var sdesc = g_form.getValue('short_description');
if(sdesc.indexOf('Request for New CI Creation - ') > -1 || sdesc.indexOf('Request for CI Update - ') > -1){
//alert(index);
g_form.setDisplay('variables.spaceholder',false);
g_form.setDisplay('variables.spaceholder2',false);
g_form.setDisplay('variables.spaceholder3',false);
g_form.setDisplay('variables.spaceholder4',false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2014 07:49 AM
I'm completely sure that it has to work as a client script. If you want to hide it only on the change_request form, you have to create a client script onload on changeRequest table and to add this line. Please, check if the variable is mandatory, if so, it will not work. To fix it, you have to put the variable as not mandatory and to create a Catalog UI Policy which set it to mandatory. Doing that, the script will hide it without any problem.
Let me know if it works.
Regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2014 08:36 AM
I inputted this script:
function onLoad() {
//Type appropriate comment here, and begin script below
var sdesc = g_form.getValue('short_description');
var index = sdesc.indexOf('Request for New CI Creation - '||'Request for CI Update - ');
if(index == 0){
//alert(index);
g_form.setDisplay('variables.spaceholder',false);
g_form.setDisplay('variables.spaceholder2',false);
g_form.setDisplay('variables.spaceholder3',false);
g_form.setDisplay('variables.spaceholder4',false);
}
}
It was working prior to adding the ||'Request for CI Update - ' into the code. Can I add an or condition in this? I'm fine with creating a second script but it's on the same table so I think it would just be easier this way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2014 08:42 AM
The syntax for the or condition is not correct. Something like the following should work:
function onLoad() {
//Type appropriate comment here, and begin script below
var sdesc = g_form.getValue('short_description');
if(sdesc.indexOf('Request for New CI Creation - ') > -1 || sdesc.indexOf('Request for CI Update - ') > -1){
//alert(index);
g_form.setDisplay('variables.spaceholder',false);
g_form.setDisplay('variables.spaceholder2',false);
g_form.setDisplay('variables.spaceholder3',false);
g_form.setDisplay('variables.spaceholder4',false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2014 08:59 AM
I got it working - thank you!