How do I pass the sys_id from the UI action condition to a script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 03:35 PM
Hello,
I would like to pass the sys_id of a change_request to a script include.
The background is that I ran out of room on the condition filter for my UI action that is on the change_request table. I was told that I can use a script include. So I did, but for some reason I can't pass the sys_id of the change request to from the UI action to the change_request. I have spent so much time trying to figure out what the issue is. Please help. Thanks in advance.
Here is the condition on my UI action:
!(new hasImpTask().hasImplementationTask(current.getUniqueValue()))
Bellow is the script include:
var hasImpTask = Class.create();
hasImpTask.prototype = {
initialize :function(){},
hasImplementationTask: function(sysid) {
var gr = new GlideRecord('change_task');
gr.addEncodedQuery('change_request=' + sysid);
gr.query();
while(gr.next()){
if(gr.getValue('change_task_type') == 'implementation'){
return true;
}else if(gr.getValue('state') != 3 && gr.getValue('state') != 4 && gr.getValue('change_task_type') != 'review'){
return true;
}
}
return false;
},
type :'hasImpTask'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 04:55 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 05:16 PM
Hi,
If you are using Out of the box UI Action you have to first check the sys_class_name == change_request
else
you can update below condition in your UI ACTION Condition
!hasImplementationTask(current.getUniqueValue())
script include:
NAME: hasImplementationTask
Client Callable : FALSE
// UPDATE YOUR SCRIPT INCLUDE WITH BELOW AND CHANGE FUNCTION PARAMETER TO CURRENT
function hasImplementationTask(current) {
var gr = new GlideRecord('change_task');
gr.addEncodedQuery('change_request=' + current.getUniqueValue());
gr.query();
while(gr.next()){
if(gr.getValue('change_task_type') == 'implementation'){
return true;
}else if(gr.getValue('state') != 3 && gr.getValue('state') != 4 && gr.getValue('change_task_type') != 'review'){
return true;
}
else
{
return false;
}
}
}
Thanks,
-Vinay.