Skip to Content
0
Dec 16, 2022 at 09:24 PM

Using setInterval() with Slipstream for Dynamic Tile Info

259 Views Last edit Dec 19, 2022 at 06:58 PM 22 rev

I'm working on a dashboard to monitor a picklist and display the current status of various items. Ideally, I don't want to have to refresh the screen constantly. I'm planning on calling an RFC to get the values, but I'm having issues getting this to run more than once. So far, I've found the suggestion by Tamas Hoznek to use setInterval() in an onLoad script, and the use case seems identical to mine, but it still only runs a single time. Krists Magons also has a setInterval() suggestion, but it seems to break in other ways. Has anyone successfully implemented something like this? Calling background data through web workers or some kind of a constant async script without interrupting the user session seems like a nice tool to have.

Here's an example:

/* globals setInterval, console */
setInterval(getLiveNumbers(), 10000); //run the function at 10 second intervalsfunction getLiveNumbers() {
let numVal = session.findById("wnd[0]/usr/lblPersonas_167122239434233"); //Label to display info
let oRFC = session.createRFC("MSS_GET_SY_DATE_TIME"); //Get system time RFC (standard RFC)
oRFC.requestResults(["SAPTIME"]);
oRFC.send();
let _SAPTIME = oRFC.getResult("SAPTIME");
numVal.text = String(_SAPTIME); //Update the label text
console.log(_SAPTIME); //Log the RFC return
}

Edit: Still having issues with the code box. Here's my original:

/* globals setInterval, console */

setInterval(getLiveNumbers(), 10000); //run the function at 10 second intervals

function getLiveNumbers() {

let numVal = session.findById("wnd[0]/usr/lblPersonas_167122239434233"); //Label to display info

let oRFC = session.createRFC("MSS_GET_SY_DATE_TIME"); //Get system time RFC (standard RFC)

oRFC.requestResults(["SAPTIME"]);

oRFC.send();

let _SAPTIME = oRFC.getResult("SAPTIME");

numVal.text = String(_SAPTIME); //Update the label text

console.log(_SAPTIME); //Log the RFC return

}