How to hide ui action based on date condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 09:28 AM
Hi,
I would like to make visible of button in form only when "end date" field is within 30 days else it should be hidden.
For example: If "end date" has current value then that button in the form should be visible for next 30 days of current value.
Can anyone please help me with this?
Thanks,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 09:33 AM - edited 02-27-2023 09:35 AM
Please call a script include in the condition field of UI action like below:
And in the function you can compare the dates and return true/false accordingly like below
I hope you get the idea, how we can achieve this.
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 09:38 AM
Thanks for your response @Prince Arora
The condition should be 30 days from "end date" field. Say for example: end date has value "27/2/2023" then the button should be visible next 30 days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 09:45 AM
In this case, you can add 30 days in the end date and then compare both,
var gdt = new GlideDateTime(endDate);
gdt.addDays(30);
var gdtStr = gdt.toString();
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 11:59 PM