cancel
Showing results for 
Search instead for 
Did you mean: 

time delay in script next step in sap screen personas

Ritz
Active Contributor
0 Kudos

Hello Experts,

I am generating a message on screen in text box after that I want it to be vanish in 1 second and carry out further steps in script.

I see a similar question but the reply by expert @ chinthan.yajamaan in it gives reference of another post which i am unable to locate.

https://answers.sap.com/questions/12029942/personas-20-how-to-impplement-a-time-delay-during-.html?c...

Appreciate you replies.

Thanks

RD

Accepted Solutions (1)

Accepted Solutions (1)

kmagons
Advisor
Advisor

Hi Ritesh,

You can use the JavaScript Window setTimeout function to execute a script that clears the message after the given time in milliseconds.

1) Create an SAP Screen Personas script that clears the message, for example:

session.findById("wnd[0]/usr/txtPersonas_161305201704022").text = "Cleared!";

2) Create a script that features a timer and calls the previous script asynchronously to clear the message

session.findById("wnd[0]/usr/txtPersonas_161305201704022").text = "Message!"; 

setTimeout(function(){
session.utils.executeScriptAsync("wnd[0]/scrptPersonas_42010AEEDAD41EDB9B8E51F86BC5303B");
}, 1000);

Hope that helps!

Best regards,

Krists Magons

SAP Screen Personas Dev team

Ritz
Active Contributor
0 Kudos

Thanks kmagons, let me try that.

Ritz
Active Contributor
0 Kudos
kmagons

can i combine all ( generation and clearance) in my current script only?

as my trigger start with one push button by user. once start it perform few steps an generates a success message in botton message bar, from there I am collecting the message and passing it to text field on screen. here i wan it to be displayed for 1 second and then disappear and go to next steps.

Thanks

RD

kmagons
Advisor
Advisor

JavaScript is executed in a single thread and most of the property changes such as the text property generate async network requests, therefore, to ensure the request responses do not interfere with your timers, I highly recommend to use session.utils.executeScriptAsync along with a separate script that implements the logic to be executed after the timer.

Thanks,

Krists

Answers (3)

Answers (3)

Ritz
Active Contributor
0 Kudos

kmagons,

It work out finally . Thank you friend , you are awesome . 🙂

Thanks

RD

tamas_hoznek
Product and Topic Expert
Product and Topic Expert

Yes, he is 🙂

Ritz
Active Contributor
0 Kudos

kmagons,

I tried with below but after message appear on screen its going in loop and hang there. 😞

also for setTimeout it gives below error

so i even added /* globals setTimeout */ , flavour got saved but aftertward it shows same error again and it didnt show the declaration (/* globals setTimeout */) i added previously.

Thanks

RD

kmagons
Advisor
Advisor

Hi Ritesh,

The window.setTimeout method is available globally. Either ignore the warning or add /*globals setTimeout*/ to the top of the function that leverages setTimeout call to suppress the warning.

You are calling the same script recursively every second to the point when the recursion stack is full 🙂 You need to have at least 2 SAP Screen Personas scripts:

- One that sets the timer through the setTimeout function

- The other that implements the logic to be executed when the timer is done

In the first script, use session.utils.executeScriptAsync and pass the other's script's ID to call logic that should be executed when the timer is over.

Thank you!

Krists Magons

SAP Screen Personas Dev Team

Ritz
Active Contributor
0 Kudos

kmagons,

I am trying below all in same script but some how its not working , also i am not sure which object id should i pass in last line. Pasted below all three steps. Please share your thoughts.

// collect task bar message in "message"

var message = session.findById("wnd[0]/sbar").text;

// pass task bar message to custom filed on screen session.findById("wnd[0]/usr/subPersonas_161304253978389/txtPersonas_161304262034397").text=message;

// call clear message function after 1000 milisecond

setTimeout(function(){ session.utils.executeScriptAsync(" which parameter should i specify here ? "); }, 1000);

Thanks

RD

kmagons
Advisor
Advisor

You need to pass the SAP Screen Personas script ID that you want to call once the timer finishes as an argument to session.utils.executeScriptAsync

Ritz
Active Contributor
0 Kudos

Thanks , Let me try that.