- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2024 08:51 AM
I currently have a hidden URL field made and I want it to appear in my Generic Request form once I select a Configuration Item that has a specific URL value I put in the CMDB.
If the chosen Configuration Item has the "URL required" field set to "yes" on the CI listing, then:
1. Show the "URL" field on the Generic Request form (i.e. make it visible)
2. Make the "URL" field mandatory on the Generic Request form
I have attached a snippet of what I have so far and I don't know why it's not working as in when I select a Configuration Item that has the URL value that I put in the CMDB, that the script looks for, it should then make the URL field appear on my form and make it mandatory.
Please help and let me know what I should do in detail. Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 06:12 AM
@msekla , it might be because of setVisible so try replace this with setDisplay()
g_form.setDisplay('url',true);
replace in both if and else if
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 11:51 AM
Last issue I am having is that how do I make the URL field hide again if a configuration item that does not have a URL field required. Lets say I select a configuration item that does need a URL required and the URL field appears on the form as intended, then I select a different configuration item that does not need a URL required, the URL field still stays there on the form as a required field and that's not ideal. What would I need to change in either script for the URL field to disappear if a configuration item that does not require it is selected without needing to refresh the page in order to hide the URL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 12:14 PM
@msekla ,i just checked in my pdi without refreshing also that is happening, for 2nd time if user select a ci which does not have url required true it will hide the URL field, please check your code whether it is same as my code? check client script mainly
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 12:19 PM
This is what my code looks like and everything is working perfectly except that the URL does not hide if I select a configuration item that does not need a URL.
Client Script:
Script Include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 12:35 PM - edited ‎03-05-2024 12:38 PM
@msekla your client script code is a little bit different please check the part,
in your code if, else if is missing please correct it
function getResponse(response){
var ans = response.responseXML.documentElement.getAttribute('answer');
{
g_form.setVisible('ccw_url',true);
g_form.setMandatory('ccw_url',true);
}
}
my code:
function getResponse(response){
var ans = response.responseXML.documentElement.getAttribute('answer');
alert('answer' + ans);
if(ans == true || ans == 'true')
{
g_form.setVisible('url',true);
g_form.setMandatory('url',true);
}
else if(ans == false || ans == 'false'){
g_form.setMandatory('url',false);
g_form.setVisible('url',false);
}
}
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 12:46 PM
For some reason with your code the URL field never appears even if I select a configuration item that does need a URL but with mine it actually appears if I select a configuration item that does need a URL.