How do you run the client side AND the server side in UI Action page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2024 04:58 PM
Hi all,
I’m currently working on a UI Action where I need to execute both server-side and client-side logic when the user submits a record. Specifically on the Client side, I want to make the record "read-only" once it has been selected and submitted from the table.
However, I’m encountering an issue with the 'Client = true' configuration. It’s throwing errors, and I’m unsure if there’s something I need to adjust in the OnClick field or the Workspace Client Script.
I tried renaming the field to match the client script and the OnClick field, but that led to additional issues. Could anyone please advise on the best approach to resolve this and ensure both server-side and client-side code run correctly?
Thank you for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2024 06:59 PM
Perhaps understanding the parts a little better will help.
Action name is the name of your action. It is not what action will happen. It is specific to your action. If you want to use gsftSubmit(null, g_form.getFormElement(), 'your_action_name_here'); you have to use whatever you put in as your action name.
Onclick is the function that is called when you click on the UI Action. I would avoid using overly common function names such as onClick or onSubmit but instead use something more relevant to what your action is doing.
This is the function that will be called in the Script when you click the UI Action on the Client Side.
Then you will need another function for Server Side. This is called by
if (typeof window == 'undefined') nameYourServerSideFunctionHere();
Finally, make sure that both your functions are in your script!
I like to see how things are connected, so I'm including a screenshot of an OotB UI Action that perfectly demonstrates this and I've color coded which parts are connected.
Official Documentation here:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 08:04 AM
Thanks for your reply and for color coordinating everything! I tried adding `setRowReadOnly()` under the `onclick` function, but I’m getting a “g_form is not defined” error. When I try to pass 'g_form' as a parameter, I get an error saying that 'g_form' is undefined. How did you get the code above to work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 01:35 PM
Did you check the "Client" checkbox? Is the g_form being used in the function that you listed in the onClick field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 02:35 PM - edited 12-10-2024 02:38 PM