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-12-2025 04:22 AM
Hi @MaharshiC
try the below script to set a delay of 10 seconds beofre executing the main logic.
var setTimer = setTimeout(setTimerDelay, 10000);
function setTimerDelay() {
alert('10 Seconds delay');{
//Your logic here
}
}
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 10:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 10:57 PM
can you share your UI action script?
is it client side or server side?
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-20-2025 02:04 AM
Hi @Ankur Bawiskar ,
This is the UI Action
function onClick(g_form) {
var errorMsg = false;
var validatorFieldsFromTaskTable = ["no_of_tags_reviewed"];
for (var i in validatorFieldsFromTaskTable) {
g_form.setMandatory(validatorFieldsFromTaskTable[i], true);
if (g_form.getValue(validatorFieldsFromTaskTable[i]) == "") {
errorMsg = true;
}
}
if (errorMsg == true) {
var errorMessage = "Fill the Mandatory Fields : Review Items. Please fill and save then click on Request endorsement";
g_form.addErrorMessage(errorMessage);
}
//g_form.addInfoMessage("Dev is in progress");
if (errorMsg == false) {
var requestEndorsementObj = {
task_sys_ID: g_form.getUniqueValue(),
action: "Request Endorsement"
};
var ga = new GlideAjax("x_iem_tqa.tqaTaskCreationUtils");
ga.addParam("sysparm_name", "validateAction");
ga.addParam("sysparm_requestEndorsementObj", JSON.stringify(requestEndorsementObj));
ga.getXMLAnswer(function(answer) {
if (answer) {
g_form.addInfoMessage(answer);
}
setTimeout(function() {
g_form.reload();
}, 10000);
});
}
}