OnSucess Event Does Not Guarantee Data In Expressions

Wappler Version : 5.3.0
Operating System : W11
Server Model: NodeJS

I have a SC which fetches some data. On success dynamic event, I call a Page Flow, which uses a value from this SC to call another SC.
But, every time, when the flow runs, the SC binding is empty.
To around this, I changed the success dynamic event to inline flow and added a 100ms Wait as the first step. Now the flow works fine and second SC is called with correct values.

This is an unacceptable setup. The steps inside flows are already unsynchronized, so have had to use JS many times to do something that could have been done with a flow.
This new timing issue is really bad, so creating this bug report.

On success/done/error or any such event, the data of server connect should always be available. The event should not fire if the data is not yet available in the dmx objects.

I don’t see any problem with my setup, but if there is, please let me know. If not, please improve this.

The success event triggers after the data has been updated, it should be available in the event. Other components on the page are not yet updated, so when you use the data for example in a value component and then access the value from that component it will not have the updated data. The other components on the page are updated in a next cycle.

Not really sure if I am following you here.

The binding that I have in page flow is something like: scDetails.load({ businessID: scBusiness.data.q1.id }) this.
And this flow is being called on success event of scBusiness SC. But, scDetails is loaded without businessID.
Are you saying that the binding in the flow is parsed in a separate cycle… and not when it is actually called?

Do you have the noload attribute checked for the scDetails one? If not, it will load when the page is ready and then again when the onSuccess is triggered

I use inline flows a lot and have never had an issue where the data isn’t available from a Dynamic on Success event

1 Like

Yes.

I haven’t had any issues either, from what I recollect. But just yesterday it failed.

1 Like

The code should work as you have it. I will do some testing and see if I can replicate your problem. Have you tried calling the scDetails.load({ businessID: scBusiness.data.q1.id }) directly on the success event instead of a page flow to see if it makes some difference.

It does work when used directly.
But I need it in a page flow for reusability and other conditions.

I’ve tested it with a page flow and it works for me. How are the components nested on your page?

Its in a partial.
Layout > Content > Partial > Page Flow and both Server Connects
On load of content page, first SC is auto-load. On success, it calls page flow.

My test was also in a partial. I’ve also tried changing the order of the components, it just always passes the value.

My test page content:

<!-- Wappler include head-page="layouts/main" fontawesome_5="cdn" bootstrap5="local" is="dmx-app" id="test123" appConnect="local" -->
<meta name="ac:route" content="/test123">

<script is="dmx-flow" id="flow1" type="text/dmx-flow">{
  run: {
    action: "{{serverconnect2.load({sort: serverconnect1.data.sort})}}"
  }
}</script>
<dmx-serverconnect id="serverconnect1" url="/api/test1" dmx-on:success="flow1.run()"></dmx-serverconnect>
<dmx-serverconnect id="serverconnect2" url="/api/test2" noload></dmx-serverconnect>

My App Connect version:

/*!
 App Connect
 Version: 1.14.9
 (c) 2022 Wappler.io
 @build 2022-11-28 10:36:35
 */

I will try to re-create in a test project, and share that. Thank you for testing this out so far.

On your page you probably have a lot more components and scripts that can have some effect on it. In our tests we keep it simple and test only the functionality of a specific component and some combinations with components it should work together with. If you are able to reproduce it on a simple page where we then we can pinpoint the problem would really help.

1 Like

The system is in development stage. So I will check if I can share credentials with you in case the problem does not reproduce in a simpler setup.

Tried to replicate multiple times now, but unable to do so.
On both new project and the existing one, it is now working as it always does. Not sure why it kept failing yesterday.

I have a new issue with flows and data, will open a separate thread for it.