UI Action Visibility

Ram khile123
Tera Contributor

Hello Folks,

I have a requirement I want to hide button from incident form for next 24 hours once clicked it and after 24 hours again its visible or abort action if user click it within 24 hours once he click first time. I tried to use below code in ui action script but its not working.

 var diffInHours = gs.dateDiff(lastClicked, gs.now(), 'hours');
            if (diffInHours < 24) {
                return false;
}

 

Much Appreciated!!

Thanks

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Ram khile123 

you will require some field to hold the time when it was clicked last time.

When it's 1st time the field will be empty so show always.

From next time onwards you can use UI action condition to compare that

current.custom_field == '' || (Script Include code and pass the custom field and check difference)

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader