Highlighted
Valued Contributor.
Valued Contributor.
893 views

Delay in Java Script

Jump to solution

Hi team.

I need to include a delay in java script for some requirements web services. I did this code but I feel that the function setTimeout is not in the set of the instructions.

Does anybody know how can include a delay in javascript
thanks a lot

var y=system.functions.tod();
print(y);


setTimeout(doSomething,3000);

function doSomething() {
//do whatever you want here
var z=system.functions.tod();
print(z);
}                       

0 Likes
1 Solution

Accepted Solutions
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Delay in Java Script

Jump to solution

Hi @cera721430

SM js executung on server side,  setTimeout will  not work 

Try this 

var timeOut  = new Date(new Date+30000).valueOf()
var current  = new Date().valueOf()
while (true) {
  if (timeOut<current) {
    //your web service call here 
    return;
    }
  }

HTH

 

View solution in original post

3 Replies
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Delay in Java Script

Jump to solution

Hi @cera721430

SM js executung on server side,  setTimeout will  not work 

Try this 

var timeOut  = new Date(new Date+30000).valueOf()
var current  = new Date().valueOf()
while (true) {
  if (timeOut<current) {
    //your web service call here 
    return;
    }
  }

HTH

 

View solution in original post

Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Delay in Java Script

Jump to solution

Yeah, webservices do need a delay sometimes.

I've therefore coded a "delay" by opening a long text file for reading and looping it through just to keep server busy and not throwing a timeout exception.

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Delay in Java Script

Jump to solution

And forgot, newer versions of SM contain the popular Underscore JS library, which contains timeout functionality, but. in SM implementation..

if(!this.setTimeout) {
  function setTimeout() {
    throw new Error("Service Manager doesn't support setTimeout function!");
  }
}

...so if you'd like to use timeout in GUI programming, it's not possible.

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.