Wait for events not working on setup line

Hi, I’m upgrading a 19.1 process to my 22.1.38 pega software but when I test the automation the wait for event component is not working. Always goes to timeout line and doesn’t enter in the setup line.

@MichaelR6943 This is a tricky one to explain but I think one of two things might be happening for you.

It is important to understand how a wait for event (WFE) works. The timer portion of the WFE actually starts in parallel to the setup thread. This is to allow you to trigger the event while it is being waited for. Without this, you might click a button, and the click event might actually fire before the WFE started waiting (and would then timeout since it did not detect that event during its waiting period). This also means that if I had a WFE whose timeout was set to 5000 ms and off of my setup thread I click a button (to cause the event I am waiting for to happen) and then pause for 5000 ms, it will always timeout. Another consideration you need to make with WFE is during debugging. If you try to step through a WFE, that time that you take getting to each breakpoint is occurring within the timeout period. If your timeout is short enough, that added time of stepping through each link might run you past the timeout value even though your event happened.

In your screenshot, I can see a potential for both of these things to be happening. I would suggest you place your breakpoints after the WFE (on timeout and on fired) instead of before the WFE. If you do have breakpoints before the WFE, select continue instead of stepping through the WFE. I would also suggest you remove your pause during the setup. The setup link should only be used for the automation step that actually triggers the event to happen.

@ThomasSasnett

Thank you for your replay, as you can see in the screenshot, I have a performclick in setup line, this never happen even though if I debugging or not. The wait for event timeout it’s 60000ms and the pause at the setup line is just 5000ms. I take the consideration of deleting this, but this not solve the problem.

When the automation It’s inside the WFE component, if I make the performclick manually works, that is why I said it never goes inside the setup line.

@MichaelR6943I would like to know if the PerformClick method working as expected. Would you please try a simple automation where you trigger the perform click only? Does that trigger your page to get created? If the PerformClick is working, then I would do the following.

  1. Remove the pause within your setup block.
  2. Make sure you enable your Runtime logging and set the levels to DEBUG.
  3. Write a log message before your wait for event block. You can do this directly from the execution link by clicking the gray line and then opening the properties window on the right. There will be a property for the execution link named “LogBeforeExecution”. In here, enter your log message. I always start mine with "***LOG - ". This allows me to easily search for them.
  4. Write a log message during the setup. You can use the execution link connected to “BtnAceptar.PerformClick” for this message.
  5. Write a log message on the links from Fired and from Timeout from the WFE block.
  6. Add the Created event for scrMensajes somewhere else in your automation. This is temporary. Write the created event to a log message. Since you won’t have any execution paths here, I would use the LogInfo method from the Toolbox to write this message (the log messages you add to the execution links are logged at the INFO level).
  7. Run your automation without any breakpoints and examine the logs. This will give us an idea of what is happening.

@ThomasSasnett Thank you for your support!

Somehow the WFE worked. I just removed all the breakpoints near to de WFE and let the flow run. If I set a breakpoint on setup or fire line the automation gonna stop on timeout line.

Thank you again for the support!