Monday, 17 December 2018

settimeout / Sleep / wait in ServiceNow


setTimeout in ServiceNow


function onChange(control, oldValue, newValue, isLoading) { 
if (newValue == oldValue){
return;
}  
window.setTimeout(Test,4000);
}  
function Test(){
// do your stuff here
alert('Wait for 4 Seconds.');
var caller = g_form.getReference('<field_name>');

}
Note: You should always use setTimeout(Test,4000) instead of setTimeout(Test(),4000); 


Sleep in ServiceNow
Note : We cant user gs.sleep function in scooped application it has to be used in non-scooped application
sleep: function (duration) {
gs.sleep(duration);
},

No comments:

Post a comment