- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 01:08 AM
Hi,
I need to add a condition on a UI Action button to only show it for cases that were resolved more than 7 days ago.
Struggling with the correct syntax, can anyone help?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 01:41 AM
use this condition - current.resolved_at && current.resolved_at <= gs.daysAgo(7)
this will applicable on records which resolved on 7 days ago or more than that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 01:36 AM
Hello @mark_oldroyd ,
You can update your UI Action condition with the following code, which I’ve tested in my PDI, and it worked as expected:
(current.resolved_at && gs.daysAgo(current.resolved_at) > 7)
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 01:41 AM
use this condition - current.resolved_at && current.resolved_at <= gs.daysAgo(7)
this will applicable on records which resolved on 7 days ago or more than that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 01:52 AM
You can't directly put this in you condition field. And assuming you don't want to create a field on the table just for a ui action to show or not, you will need to create a script include and call that from your ui action.
Check if below will work for you:
var CheckResolvedDate = Class.create();
CheckResolvedDate.prototype = {
initialize: function() {},
isResolvedMoreThanSevenDaysAgo: function(recordSysId) {
var gr = new GlideRecord('sn_customerservice_case');
if (gr.get(recordSysId)) {
if (!gr.resolved_at) {
return false;
}
var resolvedAt = new GlideDateTime(gr.resolved_at);
var sevenDaysAgo = new GlideDateTime();
sevenDaysAgo.addDaysUTC(-7);
return resolvedAt.before(sevenDaysAgo);
}
return false;
},
type: 'CheckResolvedDate'
};
and call it like "CheckResolvedDate.isResolvedMoreThanSevenDaysAgo(current.sys_id)"
"
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark