Client & Server code in UI Action

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 03:45 AM
Hi,
I'm probably missing something very basic here but I'm not able to execute both client and server side code in my UI Action
This is the script:
function doClient() {
alert("here " + g_form.getFormElement())
gsftSubmit(null, g_form.getFormElement(), "server_side");
}
if (typeof(window) == undefined) {
doServer()
}
function doServer() {
gs.error("server")
action.setRedirectURL(current)
}
This is how the UI action is set up
When I hit the button, the code executes the client-side (alert), but never executes the gs.error command.
Thanks,
Nicola
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 07:37 AM
gs.error() should work fine
I did some small changes; please check if it works fine
function doClient() {
alert("here " + g_form.getFormElement());
gsftSubmit(null, g_form.getFormElement(), "server_side");
}
if (typeof(window) == undefined) {
doServer();
}
function doServer() {
gs.addErrorMessage("server");
action.setRedirectURL(current);
}
Regards
ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2022 08:30 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2022 01:55 AM
Hi, no, I don't see any change. While the client-side is executed, it seems like the server-side of the UI action is never executed. I think gs.error of gr.addErrorMessage doesn't make much difference...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 09:13 AM
Hi,
can call the servers script from client script in UI action ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2024 03:48 AM
Hi,
It's an old question, but in case somebody has the same issue.
The type for "undefined" in the "if" statement must be a String:
if (typeof(window) == "undefined") {
Best regards.