- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2022 07:43 PM
I want to know when the service portal widget script is executed.
Does the server script work when the widget is executed (such as when a button is clicked)?
Or is there an item to set the script execution timing?
Regarding the client script, the code is written in "function ($ scope, spUtil, spUIActionsExecuter, spModal) {}", but I'm not sure if the execution timing is at the time of loading.
I'm thinking of customizing the default "Approve" widget, but I want to understand the default code content before customizing it.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2022 11:30 PM
The server script part is basically executed on widget load first, if you do not add any IF condition to that code block. This can be used to pre-set widget options from script, populate some scope data variables, run Glide Records before passing data to client etc.
You can call the server script "ad-hoc" from a client script by using spUtil.get(). The unconditional server script wil also be re-called any time you use spUtil.update() or spUtil.refresh().
To add extra code from a click of a button, you would typically add a "ng-click" in the HTML part, connected to a function in the client script, which then uses spUtil.get() to pass scope data to server and specify which server-side function to run. Look up some examples of using spUtil.get() online and you will see the pattern.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2022 11:30 PM
The server script part is basically executed on widget load first, if you do not add any IF condition to that code block. This can be used to pre-set widget options from script, populate some scope data variables, run Glide Records before passing data to client etc.
You can call the server script "ad-hoc" from a client script by using spUtil.get(). The unconditional server script wil also be re-called any time you use spUtil.update() or spUtil.refresh().
To add extra code from a click of a button, you would typically add a "ng-click" in the HTML part, connected to a function in the client script, which then uses spUtil.get() to pass scope data to server and specify which server-side function to run. Look up some examples of using spUtil.get() online and you will see the pattern.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2022 05:13 PM
Thank you for answering!
It was easy to understand!