- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 04:41 AM
Hi Folks, I have a requirement from the client when the incident state is on hold then I have to show the "Close" UI action after 30 days from when it was on-hold. can someone help me on what I have to write UI action condition?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 05:33 AM
Hi @Community Alums ,
If you already have the date available you can just use this much peice of code
var checkDate = Class.create();
checkDate.prototype = {
initialize: function() {},
verifydate: function(date) {
var gdt = new GlideDateTime(date);
var nowTime = new GlideDateTime();
var duration = GlideDateTime.subtract(nowTime, gdt);
var days = duration.getDayPart();
if (days >= 30) { // modify the condition as per your need this is if 30 days or more then close button will appear
return true;
}else{
return false;
}
},
type: 'checkDate'
};
pass the date in this condition on UI action
new checkDate().verifydate(current.on_hold_date); // kindly use proper backend name of the on hold date field
Please mark my answer helpful & solution accepted if it resolves your query.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 05:33 AM
Hi @Community Alums ,
If you already have the date available you can just use this much peice of code
var checkDate = Class.create();
checkDate.prototype = {
initialize: function() {},
verifydate: function(date) {
var gdt = new GlideDateTime(date);
var nowTime = new GlideDateTime();
var duration = GlideDateTime.subtract(nowTime, gdt);
var days = duration.getDayPart();
if (days >= 30) { // modify the condition as per your need this is if 30 days or more then close button will appear
return true;
}else{
return false;
}
},
type: 'checkDate'
};
pass the date in this condition on UI action
new checkDate().verifydate(current.on_hold_date); // kindly use proper backend name of the on hold date field
Please mark my answer helpful & solution accepted if it resolves your query.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 05:35 AM
Hi @Danish Bhairag2 Thanks for the reply it worked for me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 05:36 AM
@Community Alums You can achieve this implementation by making the following changes.
1. Define a custom field u_on_hold_since this should be a date type field.
2. Create a onBefore update business rule which will trigger whenever the state of the incident changes to On Hold
set the value of u_on_hold_since with the current date in the script.
3. Create another onBefore update business rule which will trigger when the state changes from On Hold to some other state.
set the value of u_on_hold_since date to nil
4. On this step, you need to open your Close UI Action record, on the condition field use a script include to check if the current.u_on_hold_since is at or before 30 days from the current date the script include method should return true/false to set the visibility of the UI Action.