- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 10:13 AM
Hi All,
I have created a UI action in Scoped Application to show on the Case form when the 1st Task created is moved to Closed state .
This UI action should only be visible when Step 1 task is closed . I am making a call to Script Include to query the table and return 'true' Or 'false' .
The Condition used to restrict the visibility of UI action is not working . Could you let me know if I am missing something in my Script .
Below is the UI Action
Below is the Script Include :
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
initialize: function checktaskclosure(current) {
var grt = new GlideRecord('sn_hr_core_task');
grt.addQuery('parent', current.sys_id);
grt.addQuery('short_description', 'Step1 Task');
grt.query();
gs.info('the returned records are :' + grt.getRowCount());
var gh = grt.state;
if (gh == '3') {
return true;
}
else{
return false;
}
},
type: 'SteptaskUtils'
};
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 04:16 PM
hi, could you please test this one
in condition, we will pass object current
new sn_hr_core.SteptaskUtils().checktaskclosure(current);
script include as below
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
initialize: function(){},
checktaskclosure: function(current) {
gs.info('Into the Script Include:');
var grt = new GlideRecord('sn_hr_core_task');
grt.addQuery('parent', current.sys_id);
grt.addQuery('short_description', 'Step1 Task');
grt.query();
gs.info('the returned records are :' + grt.getRowCount());
if(grt.next()){
var gh = grt.state;
gs.info('the state value is :' + gh);
if (gh == '3') {
return true;
}
else{
gs.info('Into Else:');
return false;
}
}
},
type: 'SteptaskUtils'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 12:17 PM
Hi ,
I updated my script as below still the UI action is appearing on form and not matching the condition only After Step 1 task is closed.
In the condition field of the UI action I gave like below .
new sn_hr_core.SteptaskUtils().checktaskclosure(current.sys_id)
Script include :
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
initialize: function checktaskclosure(current) {
var grt = new GlideRecord('sn_hr_core_task');
grt.addQuery('parent', current.sys_id);
grt.addQuery('short_description', 'Step1 Task');
grt.query();
gs.info('the returned records are :' + grt.getRowCount());
if(grt.next()){
var gh = grt.state;
if (gh == '3') {
return true;
}
else{
return false;
}
}
},
type: 'SteptaskUtils'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 02:23 PM
Hi
Could you please help me with the script on how to achieve this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 07:20 PM
you dont need to pass the current object as parameter , your script include can access the current object value directly inside function.
here we go.
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
initialize: function checktaskclosure() {
var grt = new GlideRecord('sn_hr_core_task');
grt.addQuery('parent', current.sys_id);
grt.addQuery('short_description', 'Step1 Task');
grt.query();
gs.info('the returned records are :' + grt.getRowCount());
if(grt.next()){
var gh = grt.state;
if (gh == '3') {
return true;
}
else{
return false;
}
}
},
type: 'SteptaskUtils'
};
condition :
new sn_hr_core.SteptaskUtils().checktaskclosure()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 10:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 12:24 PM
Hi
The UI action is always visible on the form from the time the record is created .
It is not matching the condition .
When I put the logs statements , I can see it is entering the Function and see below in logs
But the Next log statement is not coming , please see my Script include .I selected as 'Client Callable'
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
initialize: function checktaskclosure(current) {
gs.info('Into the Script Include:');
var grt = new GlideRecord('sn_hr_core_task');
grt.addQuery('parent', current.sys_id);
grt.addQuery('short_description', 'Step1 Task');
grt.query();
gs.info('the returned records are :' + grt.getRowCount());
if(grt.next()){
var gh = grt.state;
if (gh == '3') {
return true;
}
else{
return false;
}
}
},
type: 'SteptaskUtils'
};