Submit form with variables

Hey,

This is probably a really simple question with a simpler answer. I want to submit a GET form along with some results from server connect queries already on my page.

Form fields: user, service

Server connect actions successfully loading: get user info, get service info.
In other words, once a user is selected I grab that user’s info in a SC action. Same thing for the service. So for example, first name, last name etc.

Since my form only has two fields, using a button to submit the form works nicely.

However, how do I go about submitting something like first and last name along with my form fields?

Hey @nepatriot,
All you need to do is add hidden fields and set them with a dynamic value of the SC data. When you submit the form they will be sent with the names you give the input.

Hey @bpj,
Thanks for your reply!

It seems kind of clunky to me to have to add potentially dozens of hidden fields, populate them, and submit them.

Is there another way to add objects to the Post payload?

One way or another the data needs to be included in a form. You could send via GET through a flow but that is limited to ~2KB.

If your SC data is already structured, you could send an entire JSON as a single input. This would involve setting up a custom client-side formatter to stringify an array and one on the server to parse it. They’re not difficult to do.

Alternatively, if the data comes from SC, you could assign it to a session variable and access it in the SC as required.

If it is common user details, set up a ‘single query’ to gather the first name, surname, email etc. as required. Use the little chain icon to save and link it
image
It will then be available really quickly when you set up new SC files. This is what I do in most of my SC files:

The vast majority of them start like this


With other steps following afterwards

2 Likes

Thank you for taking the time to present all the options. It’s very helpful.

1 Like