how to make a form load slower
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hello all,
i m working on a progress tracker that will show the timestamps or visual representation of the uploads of a excel. currently i have a HTML fields that's PARSING THE ROWS AND SHOWING THEM IN INCRIMENTS BUT I ALSO WANT A PROGRESS BAR TO DO THE SAME. I HAVE A BUSINESS RULE CREATED TO slow down the uploads to see the timestamps for end users/visibility. I'm not sure its done correctly but i wanted to get input on if anyone's
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var time = 0;
while(time < 11800000) {
time++;
}
})(current, previous);
done something similar?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @DevtoSME,
have you tried this?
gs.sleep(1000); //1 second
gs.sleep(2000); //2 seconds
But if I remember correctly, this was not recommended approach... found this explanation:
https://www.linkedin.com/posts/anveshkumarmupparaju_servicenow-activity-7327264865130029056-x6Cr
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
This blocks the transaction thread on the ServiceNow server → causing performance issues, possible node crashes, and bad user experience.
Never use while-loops for artificial delays in ServiceNow.
1. Track Upload Progress
Create a custom table (e.g., u_upload_progress) or use fields on your existing record to store:
Total rows to process
Rows processed so far
Percentage complete
Timestamps (optional)
As you parse rows (via Script Include / Scheduled Job / Background Worker):
Update the progress table/field with current progress count.
On your form / portal widget / HTML field, you can use a Progress Bar UI.
Example HTML (in HTML field or widget):
<div class="progress">
<div id="uploadProgressBar" class="progress-bar"
role="progressbar"
style="width: 0%;"
aria-valuenow="0"
aria-valuemin="0"
aria-valuemax="100">0%</div>
</div>
Add a Client Script with an interval (setInterval) to poll the record/table for progress updates using GlideAjax or a REST API.
Example Client Script snippet:
function updateProgress() {
var ga = new GlideAjax('UploadProgress');
ga.addParam('sysparm_name', 'getProgress');
ga.addParam('sysparm_uploadId', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
var percent = parseInt(response);
var bar = document.getElementById("uploadProgressBar");
bar.style.width = percent + "%";
bar.setAttribute("aria-valuenow", percent);
bar.innerText = percent + "%";
});
}
setInterval(updateProgress, 2000); // poll every 2 seconds
. Script Include for Progress
Create a Script Include:
var UploadProgress = Class.create();
UploadProgress.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getProgress: function() {
var uploadId = this.getParameter('sysparm_uploadId');
var rec = new GlideRecord('u_upload_progress');
if (rec.get(uploadId)) {
return rec.u_percentage_complete.toString();
}
return "0";
}
});