- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2017 12:08 PM
Hi there,
This is related to standard change template proposal screen. In our environment while proposing change template 'Configuration field' is one of the mandatory field.
And using Configuration field look up i am able to select any CI record .But my requirement here is to restrict CI selection only for certain class.
Is there anyway to apply reference qualifiers on change template proposal screen? Please help.
Thanks
Solved! Go to Solution.
- 6,295 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2018 02:17 PM
I implemented that. Let's say you want to make a reference qualifier to the for Configuration item on the template. Then you have to create the Before Query Business Rule that looks like this (on cmdb_ci table)
(function executeRule(current, previous /*null when async*/) {
var targetName = gs.action.getGlideURI().getMap().get('sysparm_target');
if (targetName.indexOf('change_request.cmdb_ci') > -1) {
current.addQuery('install_status', 1); // installed
}
})(current, previous);
When you click the magnifying glass, there is a parameter in URL sysparm_target that always differ a little bit. On the change form it's just change_request.cmdb_ci, and on change proposal, it has format like change_request.cmdb_ci.{sys_id format}. So you can detect it like this. Then you are able to provide only specific CIs after clicking on magnifying glass.
You should also take care about the putting the Name of CI directly to the field. You cannot find the CI in the list after clicking on magnifying glass, but when you put the name into the field, it behaves as valid. Here I suggest to use client script with AJAX to check if the user put there valid CI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 05:15 AM
Did you found other way to reach this requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2020 06:38 AM
**WARNING**
We implemented this on the group table and in about 2 weeks we nearly ran out of disk space. Please see the HI Support reasoning below. I know its not exactly the code above but just a warning...
- The source of this appears to be the following Javascript error: Root cause of JavaScriptException: java.lang.NullPointerException
-- This has been traced to business rule 'ResponsibleCAB_Template Ref Qualifier' which runs against 'sys_group' --
The error is caused by the following line:
var targetName = gs.action.getGlideURI().getMap().get('sysparm_target');
-- If this gs.action function is not accessible within the execution scope it will fail with the NULL Pointer error that we have sighted
-- This appears to be the scenario when this script is run from any non-interactive sessions, such as a background worker thread
-- At present these messages appear to contribute to around 99% of the table size
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2022 03:14 PM
Has anyone found a solution to this issue?
Can we fix what is causing the error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2022 08:36 PM
Try wrapping the whole thing in a try/catch, I don't see the errors in the log any more after putting the try/catch around it.
(function executeRule(current, previous /*null when async*/) {
try {
if (gs.action.getGlideURI().getMap().get('sysparm_target')){
var targetName = gs.action.getGlideURI().getMap().get('sysparm_target');
if (targetName.indexOf('change_request.u_approver') > -1) {
current.addEncodedQuery(new StdChangeUtils().getMgrApprovers());
}
if (targetName.indexOf('change_request.u_avp_approval') > -1) {
current.addEncodedQuery(new StdChangeUtils().getAvpApprovers());
}
}
}
catch (e){
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 08:53 AM
I think this will only work if it doesn't belong to std_chg_template_val_render
please see article below