How to make a Ui action dissapear after 30 days of task closure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2024 04:43 AM
Hi Everyone,
I want to make my Ui action unavailable after 30 days when a task gets closed.
How should i achieve this?
Thanks,
Kartikey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2024 04:51 AM
What is the UI action? What is your current condition?
Something like this should work:
(current.closed_at == '' || gs.daysAgo(current.closed_at) <= 30)
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2024 05:40 AM
Hi,
This is not working, as soon as i close the task, the UI action is getting dissapeared.
Thanks,
Kartikey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2024 05:04 AM
Hi,
Try to build a condition using glide date time API so that it return true or false in a script include and call this function from UI action condition field.
Giving a sample code try to build this using the Script include and call the same from UI action condition.
var gdt = new GlideDateTime("2024-04-20 00:21:01");
var gdt1 = new GlideDateTime();
var dur = GlideDateTime.subtract(gdt, gdt1);
var diff = dur.getDayPart();
if(diff > 30){
gs.info("false")
}
If my answer helped you please mark it markfull.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2024 05:06 AM
Hi,
There is one condition field on UI action form -
I have highlighted it, in this you have to pass the condition for the visibility.
Either you can add the condition directly -
( current.closed_at == '' || gs.daysAgo(current.closed_at) <= 30 )
or add the condition in the function within script include or directly add there.