SC inserts twice, why?

Using 5.8.2 php mysql w10

I was playing with calling a sc, and found duplicated entries.
I’m having the same issue as:


And

image

I know I can do some workaround to this particular insert (disallowing null, or calling on app ready dynamic event) but there’s an specific reason on why this is happening?

What happens if you check ‘No Auto Load’?

Could it be it is loading automatically as well as how ever you are triggering it?

1 Like

Brad’s Falcon/Hawk Eye

1 Like

Thanks brad, and apple for the laugh
It’s suposed to load on default, my question goes on why the (simple) sc is running twice (with a 200 status), what’s the reason, why both request have different initiator, It’s a timing thing?

How is the “user=82” being populated? I can’t see that in the screenshot

The identity on the SC

Maybe this is on the wrong topic category, it’s more on know how it works, than how to achieve the result, as I can get that with: dmx-on:ready="serverconnectvstr.load({section: 'Clasificacion'})">

I mean, here:
SCR-20230829-bgad

  1. You left checkbox “No Auto Load” unticked, so the SC will automatically run on page load (Wappler will load it automatically)
  2. You’re also using dmx-on:ready to manually trigger a SC load

The result is the SC is loaded twice. Is that it?

No, that is the workaround: ticking no autoload and running with a ready event.

Oh oh, you got a point. I missed that, my first attemp was inserting a $_GET.user.

I deleted the param on SC but stills on page:

Removing the user param, resolves the duplicated thing.
(Still don’t know exactly why.
I want to know why giving that parameter the sc loads twice.
I guess the page loads the sc and when the user id is retrieved (few moments after), it loads again with the parameter expected)
Thanks @Apple

Good!

Yes, I guess that too. A consequence of a concept called reactivity:

Reactivity is the ability of a web framework to update your view whenever the application state has changed.

1 Like

Whenever you have a parameter linked to a dynamic value it will reload whenever that value changes.

In this case, the value (serverconnect1.data.identity) starts as empty and changes to 82 so the SC loads when empty and then loads again when 82.

Depending on your use case, there’s a few options, depending on whether you want to include the user variable

  1. Wait for the SC that returns the user variable and use the On Success dynamic event to load the visitors SC - tick no auto load to stop it running
  2. If you want it to load each time a user changes, you can use dmx-bind:noload="!serverconnect1.data.identity" which will add the noload property when the identity is not present
  3. If the user is irrelevant just remove that parameter from the SC
3 Likes