Overview
When trying to use the setTimer and sleep functions for testing purposes in the Hooks for the Delegated Admin Extensions, an error message is received, which states that they are not defined.
Applies To
- Delegated Admin Extensions
- Other Javascript scripts that do not support setTimer and sleep
Cause
The Javascript version for the Hooks is Delegated Admin Extensions is an older version that does not support the setTimer and sleep functions.
Solution
As a workaround to be able to delay the execution for the Delegated Admin Extensions Hooks, use the following code snippet:
var milliseconds = 10000;
var date = new Date();
var curDate = null;
while(curDate-date < milliseconds){
curDate = new Date();
}
In the above snippet, “milliseconds” is the number of milliseconds the execution should be paused. The execution pause should not be too long, as an error may be received if it takes too long.
It is also highly recommended to use this only for testing purposes and in no way for the end result of the Hooks.
Related References
- Click here for more general documentation regarding Delegated Admin Extensions Hooks.