UI Action Visibility
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 06:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 09:02 AM - edited 01-22-2025 09:02 AM
Hello @Ram khile123
Please apply below logic
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 10:05 AM
Thanks for reply,
This solution will work if we have value in 'datalastClicked' field. but its not working if datalastClicked field is empty. Can you suggest me how to compare if date field is empty?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 07:38 PM
Hello @Ram khile123
Did you try to put null check condition before datediff method so that It will check if datalastClicked has some value then it will executes otherwise not and makesure datalastclicked has some values and also you can use the flag variable to handle this.
Thank You
If this helps you please mark my answer as helpful or accepted solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 09:14 AM
Hello @Ram khile123
You can try with something as below
Create a field last_clicked_time (Date/Time) in the incident table
1. Retrieve the `last_clicked_time` field value from the current `incident` record.
2. IF `last_clicked_time` exists:
a. Calculate the time difference between `last_clicked_time` and the current time.
b. IF the difference is less than 24 hours:
i. Display an info message: "You cannot perform this action again within 24 hours."
ii. Abort the action.
iii. EXIT.
c. ELSE:
i. Update the `last_clicked_time` field with the current timestamp.
ii. Save the `incident` record.
iii. Proceed with the action.
3. IF `last_clicked_time` does not exist:
a. Set the current timestamp as the `last_clicked_time`.
b. Save the `incident` record.
4. Proceed with the button action logic.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.