- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2019 11:07 AM
Hello,
I am attempting to display an info message on a form with a number that will countdown to a form reload, however the number is not changing once the message shows.
This is a getXML callback for reference.
Can info messages not handle something like this?
Here is my code:
function handleResponse(response) {
var timer = 3;
var userAnswer = response.responseXML.documentElement.getAttribute('answer');
var answer = JSON.parse(userAnswer);
setInterval(function() {
timer--;
}, 1000);
g_form.addInfoMessage('The form will automatically reload in ' + timer + ' seconds');
setTimeout(reloadForm, 3000);
}
function reloadForm() {
location.reload();
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2019 11:13 AM
Change your script to:
function handleResponse(response) {
var timer = 3;
var userAnswer = response.responseXML.documentElement.getAttribute('answer');
var answer = JSON.parse(userAnswer);
setInterval(function() {
timer--;
g_form.clearMessages();
g_form.addInfoMessage('The form will automatically reload in ' + timer + ' seconds');
}, 1000);
setTimeout(reloadForm, 3000);
}
function reloadForm() {
location.reload();
}
You can get rid of the .clearMessages() if you want each message to show.
Please mark this as correct/helpful if it resolved your issue!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2019 11:13 AM
Change your script to:
function handleResponse(response) {
var timer = 3;
var userAnswer = response.responseXML.documentElement.getAttribute('answer');
var answer = JSON.parse(userAnswer);
setInterval(function() {
timer--;
g_form.clearMessages();
g_form.addInfoMessage('The form will automatically reload in ' + timer + ' seconds');
}, 1000);
setTimeout(reloadForm, 3000);
}
function reloadForm() {
location.reload();
}
You can get rid of the .clearMessages() if you want each message to show.
Please mark this as correct/helpful if it resolved your issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 06:38 AM
Please help me
https://community.servicenow.com/community?id=community_question&sys_id=aa6f9ebb1b23d810d2ccea89bd4bcbef