Opening form using server side code

What I’m trying to do:
I am trying to write a code that will open a form on the user interface but should be excuted on server side

Welcome, @naidindustries.

If you mean a browser-side user interface, remember that there may be thousands of users connected to your App, all at the same time. So there’s no clear way to say which one of them should see it.

If you mean a server-side user interface, alas, there’s no one sitting at the server to see it and respond to it. Plus, that would be a big bottleneck!

As a practical matter, Anvil allows remote procedure calls from the Client (browser) to the Server, but not the other way around.

Of course, a Form is just a means to an end. If you could tell us what this is intended to achieve, we might know of a different way to do it.

2 Likes

Once a user has logged in, the app should query the users database and confirm whether additional information such as the users name, surname , address and role have been filled. If not then the app should return a from ehre the user should input the data.

I have a similar situation. The Server can’t call the Client (browser), however, once your Client knows that log-in was successful, it can call the Server to ask it whether there is any missing information. Based on the result, the Client can ask further questions.

Yes, it’s a bit of a dance. But it makes good use of Server resources. Your Server code only runs when called upon by a Client. In between calls, the Server program shuts down completely. In this way, your App can service thousands of Clients simultaneously, with the Clients doing the bulk of the work.

There are ways to keep your Server code running, one running instance per logged-in User. But try to think of it as a last resort. The vast majority of Anvil Apps work just fine without it.

1 Like

Linking this thread which might be relevant:

2 Likes

Guys I did it, yay!!!

3 Likes