Setting session on server action 'success' endlessly repeats server action

I have a server action that outputs a session_id (UID variable). I try to save that variable as a session in the browser.

However, by setting that up using dmx-on:success="session1.set('license_session_id',claim_license.data.session_id)" for some reason it refreshes the server action endlessly.

Please see below:

  1. My server action when it’s still working as expected:
<dmx-serverconnect id="claim_license" url="/api/Sc_marketing/claim_license" dmx-param:session_id="session1.data.license_session_id"></dmx-serverconnect>

You can see it auto loads once when opening the page.

  1. I add the onclick event, so it becomes:
<dmx-serverconnect id="claim_license" url="/api/Sc_marketing/claim_license" dmx-param:session_id="session1.data.license_session_id" dmx-on:success="session1.set('license_session_id',claim_license.data.session_id)"></dmx-serverconnect>

It reloads the server action endlessly…

I do NOT have any action set up that loads the ‘claim_license’ server action again.

EDIT: Perhaps this is because the server action refreshes itself because the 'input’parameter changes?

Yes, server actions automatically reload when an input param value changes.

Ah by design?

Any tips on how to work around this situation right now?
I need this server action to load once on page load (with te parameter that the same server action will set if it’s successful)

Turn on No Auto Load and trigger the load on app ready or page load event.

As far as I know, the app ‘ready’ and ‘load’ events don’t work for node projects:


Do you mean something else?

I think they do but only on layout pages I could be wrong, a method I use is a auto loading app flow my situation is different slightly as mine was a server connect loading too quickly causing it to load with no params but the same logic might work here too.

Essentially I just used a app flow that was auto loading in the flow you can run the no auto load server connect this way it runs just once, and If needed check certain things are populated or adding delays to allow param population in my case.

Thanks for the input, is there a specific reason you used app flow instead of page flow? Haven’t found a need for app flows yet…

Apologies meant page flow with it been under the app tree sometimes forget it’s actually a page flow

1 Like

Haha no worries! Thanks, will play around with it :smiley:

1 Like