Pass variable to Server Connect from a Button On click Dynamic Event?

Have a masonry grid of client names with a button under each name. I would like to send the ID of the client to a server connect where a $_SESSION variable will be updated that is later used by multiple server connects.

Is the only way to send the ID through a form(get/post)? This is my first node/SPA project in Wappler.

Ultimate goal is for the user to click on the button and the “Click” event in Dynamic Events would send the ID to the server connect and then the next step in the Dynamic Events would be a Browser Go To another Route.

I’m getting so lost in server sessions, local or browser sessions, $param, etc…

Hi Sam,

You can use query parameters to pass and filter data by adding a $_GET variable in the Server Action. The $_GET variable will be available in the Server Connect input parameter list.

Query parameters can be defined by clicking on the App -> App Properties under App Structure and adding this query param to the route for the detail page.

guptast,

I think the $_GET query parameters is how I passed variables to pages awhile back in a PHP Wappler app. I’m not trying to pass the ID variable to a detail page though this time round. Instead, I need to pass the ID, when the user clicks a button, to a server connect that will adjust a server side $_SESSION variable that was established earlier on in the application. Once the $_SESSION variable on the server is adjusted, it could be used by other server connects later on in the application depending on what the user is wanting to accomplish.

I haven’t tried setting value for a Server Session like this, but this approach could work. I don’t know whether this is the correct approach due to any security implications.

  1. Setup a new Server Action say get_client_id with $_GET variable client_id.
  2. In the Server Action Set Session value as $_GET var.
  3. Add a Server Connect in the UI and select this Server Action.
  4. On the button click, load the Server Connect and provide ID value in the input parameters field client_id.

This might be a System Design mistake. If I open multiple tabs at the same time for managing different clients, it screws stuff.

This kind of state should be tied per-page (e.g.: on a variable, preferentially on the main template to allow it to persist across SPA page changes), and sent on every server connect. But that’s just my opinion, I don’t know your application :slight_smile:

Edit: To answer your question, you can make a Server Connect Form somewhere with an invisible input field. When you click the button, you change such field’s value, and submit the form (all this done through the Dynamic Event thingy)

1 Like

Apple,

You are correct, this is a system design mistake. I completely forgot that users could and will open multiple tabs of the app to compare clients after logging into the application. With this in mind it appears that even using the browser Session Storage Manager will not work either. If using the storage manager and setting a variable like client_id, if you opened another tab and in that tab changed clients, the original tab would also get changed as the storage manager is for the entire logged in user and their browser. So it would appear that in the “Click” event just adding the variable to the end of the Go To is the best option to allow multiple tabs in the browser each viewing a different client.

Or am I wrong?

I believe you’re right!

I’m not very experienced in the front-end though, so I don’t know if there’s a slightly better option. The solution you propose is good enough though!