- 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:26 PM
in your condition you are passing current.sys_id, but in script include, function takes object current, not sys id
so, you need to update your script as below
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
initialize : function() {},
checktaskclosure :function(sysid) {
var grt = new GlideRecord('sn_hr_core_task');
grt.addQuery('parent', sysid);
grt.addQuery('short_description', 'Step1 Task');
grt.query();
please let me know if it works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 12:42 PM
Hi
The UI action visibility is still not working , it is visible everytime when form loads. Please guide.
However the script started working atleast and it is entering into loop after making changes.
The condition in the UI Action is below
new sn_hr_core.SteptaskUtils().checktaskclosure(current.sys_id)
I have updated the Script include as you mentioned .
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
initialize: function checktaskclosure(sysid) {
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'
};
I have checked the log statements , I observed that it is generating the log statement for each Twice .Please see the below showing twice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 12:52 PM
could you place here the latest version of your script include?
also, in condition could you place code as below
new sn_hr_core.SteptaskUtils().checktaskclosure(current.sys_id.toString()) ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 01:15 PM
Hi ,
Please find the below Script include
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
initialize: function checktaskclosure(sysid) {
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'
};
I have updated the Condition in the UI action as below .
new sn_hr_core.SteptaskUtils().checktaskclosure(current.sys_id.toString()) ;
Request to guide me where exactly I am missing for this work .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 01:21 PM
please replace your script with the code below
and let me know if it works
var SteptaskUtils = Class.create();
SteptaskUtils.prototype = {
iinitialize: function() {},
checktaskclosure: function (sysid) {
gs.info('Into the Script Include:');
var grt = new GlideRecord('sn_hr_core_task');
grt.addQuery('parent', sysid);
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'