Add delay to my ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 04:15 AM
Hi,
I have an ui action which creates a new task. Now once its clicked it takes a few seconds for the task to get created. Now if the user clicks multiple times on the ui action at the same time then it creates multiple tasks. So i need to deactivate my ui action or add a delay of maybe 10 sec before it can again be clicked. How can this be achieved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 02:26 AM
as soon as the UI action is clicked, try to disable it
are you using that button only in workspace?
if yes then the below approach may not work as DOM may not work there
But it should work in native
Remember this solution will use DOM manipulation and DOM is not recommended
To allow DOM to run in your UI action ensure "Isolate script" field is False
If this field is not on form then from list make it false
It worked for me in native
As soon as I clicked, it added message in console log and the button got disabled
I used this line to disable that in native
document.getElementById('actionName').disabled = true; // give the action name of your ui action here
// your further code here
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 06:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 07:01 AM
then DOM won't work.
I don't think any other way to achieve is available for workspace
Solution I shared for native works for me
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 04:38 AM
you can use a field to check if it was clicked or not
Show the UI action if that field is empty
In your UI action script set that field, insert the task and use current.update() and then reload the form using action.setRedirectURL(current)
Something like this
// new task creation logic
current.u_task_created = true;
current.update();
action.setRedirectURL(current);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 05:19 AM
Hi @Ankur Bawiskar ,
We will not be able to add any additional field. Actually they are clicking on the button at the same time multiple times without allowing the form to load so its creating multiple times