Problem with Server Action execution

Problem with Server Action execution.
Example #1. Add a Server Action to the page that will send some data and get back a database record number. Then make another Server Action that will follow the first one and use the database record number received by the first Server Action. In this case there will be at least 2 attempts to run the second Server Action on the client side. The first time the data will be sent to the server without the number from the first Server Action. The second attempt will be as it should be.

Example #2. Now if you try to use the browser.device.width parameter, the same actions will happen. The first attempt to send data via Server Action will be canceled and browser.device.width will be 0 (and such data will be actually sent to the server). The second attempt will be filled with correct data. So if you are trying to collect statistics in this way, you will have 2 records for each visit to the page - not very good statistics.

I tried to move the Server Action startup to App.Ready - the problem persists. If you run it through App.Load event, everything works, but in case of data transfer from example #1 Server Action is executed only once and most often does not send the number from the first ServerAction - as a result data is not updated.

Bottom line.
Now I have divided the transfer of statistics into 2 Server Actions in auto load mode. The first one passes everything except browser.device parameters and returns the ID of the created string in the database. The second Server Action adds data from browser.device to the record with known ID. The second Server Action is executed automatically 2 or 3 times, but in the end I still get the result most of the time. I think this behavior is not correct, but in my case it is tolerable.

From what you say, it appears you have the sequence wrong. I guess you are trying to use the results of server connect 1 as the parameter for server connect 2?

  1. declare both server connects, set server connect 2 to “no Auto Load” as it does no need to run at this stage.

  1. run server connect 1 and in the dynamic events -> Server connect-> Success event, load the server connect 2 dynamically passing the parameter

image

This is necessary to allow serverconnect1 to complete before calling serverconnect2

2 Likes

Thank you! Realy good solution for example #1. I will change my code. What do you think about problem with browser.device.width property?

To be honest, don’t even understand what the problem is from your description, too vague

If you make a ServerConnect that receives data from Browser->device->width, the page will try to send data (No Auto Load not checked) to the server at least 2 times. The first time the values (browser.device.width etc) will be equal to 0. In the developer panel in Chrome you will see that the status of sending is Canceled, but the data reaches the server. Then the page will try to run this ServerConnect again and everything will be sent as it should be. You can run such ServerConnect via App “Load” event, but if the page is not loaded, the data will not be sent to the server. There are other reasons why “Load” is not suitable.

Issue already reported and under investigation

1 Like