Calling server-side script

Now that we have seen how to use client-side scripts in UI actions, we can look at taking this a step further and using client- and server-side script in the same UI action.

This can be achieved by first calling client-side script in the UI action, which then calls the UI action in the code, and therefore runs the server-side script. This is a slightly strange concept to imagine at first, so let's see how it works.

First, we need to take a look at the line of code that calls the UI action from the client-side code:

gsftSubmit(null, g_form.getFormElement(), '<ui_action_name>');

The preceding line of code calls the UI action, but this time, it will run it on the server side. When using this technique, you must ensure ...

Get Mastering ServiceNow Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.