594
Views
7
Comments
Solved
Any alternative for sleep component for using in client action
Application Type
Reactive

Hi,

I am looking for alternative solution for Sleep Component because I already have one server action in my client action if I add this sleep action, I will get performance warning.

I tried using some JS code in my workflow, but I can't see any difference because it didn't wait and execute the workflow.

Here is the workflow,

Here is the JS Code,

Can anyone help me with this?

Thanks in advance...

2021-08-04 12-19-54
Mayank Dharmpurikar
Solution

Hi,

write the below code in js :


UserImage.jpg
Sowndhar S

I actually looked for JS Code. It worked. Thanks Mayank.

2022-10-18 07-32-49
Randall Jodache Chetty

Thanks for sharing 

2023-04-16 15-25-31
Krishnanand Pathak

Hi @Sowndhar S,

Create a client action and call the Sleep server action inside the client action(Just wrapping the Server action in client action).
Then use the client action in your main flow.


Regards
Krishnanand Pathak

UserImage.jpg
Sowndhar S
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Sorry but I don't think this reply should be marked as solution!

I unmarked it as solution.

Calling the sleep server action from s cliënt action means a http request to the server. It would work with small sleep units below 100ms, generating http calls faster then tht http request can be processed.

The other reply marked as solution is the correct one use Javascript SetTimeout()

2021-08-04 12-19-54
Mayank Dharmpurikar
Solution

Hi,

write the below code in js :


UserImage.jpg
Sowndhar S

I actually looked for JS Code. It worked. Thanks Mayank.

2022-10-18 07-32-49
Randall Jodache Chetty

Thanks for sharing 

2023-02-26 23-17-33
Kshitij Raheja

Hey @Sowndhar S 

Your logic is correct the thing you are missing is javascript in OutSystems is asynchronous and because of that it doesn't wait for your setTimeout to end and just creates a new thread to solve it you have to use $resolve with it as also pointed out by Mayank

I have also attached a working oml file that you can use to test the logic yourself. Lemme know if you have any other questions, if this solves the issue please mark the answer as correct

Cheers,

Kshitij Raheja

TestApp.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.