- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 01:24 AM
hi
ihave a requirement that, we need to hide the close task button and close complete option in state field on change task when rfc record is created on change request and change task short description contains System Test & Validation.
below are the code i wrote but here close task button some times is not hiding please give me your suggestion or can we take sysyid of the close task
Solved! Go to Solution.
- Labels:
-
Cost Management (ITSM)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 05:35 AM
Hi
Please find the steps you need to follow to achieve your requirement:
1) Create a Script Include and use the script as below:
var uiActionVisibility = Class.create();
uiActionVisibility.prototype = {
initialize: function() {
},
buttonDisplay : function(changeID){
var gr = new GlideRecord('u_charm_rfcs');
gr.addQuery('FieldName',changeID); // Replace 'FieldName' witht he field which is present on your Charm Rfcs table which will be a Reference field and connecting to Change record
gr.query();
if(gr.next()){
return false;
}else{
return true;
}
},
type: 'uiActionVisibility'
};
Now Close task button present on Change Task you need to add the below line to your existing Script with an AND condition and pass the Change Request ID as shown below:
current.state < 3 && current.approval != 'requested' && !current.change_request.on_hold && new uiActionVisibility().buttonDisplay(current.change_request)
Let me know how you go with this:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 03:49 AM
Hi ankur,
Ui action condition :
current.state < 3&& current.approval != 'requested' && current.state != -5 && new checkcharmrfc().charmexists(current.change_request) && current.short_description.toString().indexOf('System Test & Validation')>-1)
the above condition can we put
new checkcharmrfc().charmexists(current.change_request)
instead of the above
can we put this one
!new checkcharmrfc().charmexists(current.change_request)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 03:55 AM
Should be fine
I just shared logic; add as per your requirement
current.state < 3&& current.approval != 'requested' && current.state != -5 && !(new checkcharmrfc().charmexists(current.change_request)) && current.short_description.toString().indexOf('System Test & Validation')>-1)
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 04:17 AM
Not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 04:55 AM
please try to debug the condition one by one
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 01:32 AM
Hi,
It is recommended to use the condition field in the UI action for hiding. You can put your conditions in a script include and can call the script include in the condition field of the UI action.
Thanks
Deepankar Mathur