How to hide ui action based on date condition

Priyanka77
Tera Guru

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

4 REPLIES 4

Prince Arora
Tera Sage
Tera Sage

@Priyanka77 ,

Please call a script include in the condition field of UI action like below:

PRINCE_ARORA_0-1677519042873.png

 

And in the function you can compare the dates and return true/false accordingly like below

PRINCE_ARORA_0-1677519300727.png

 

 

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.

 

 

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.

@Priyanka77 ,

 

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();

PRINCE_ARORA_0-1677519885689.png

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

 



 

@Priyanka77 .

 

Have you tried this?