- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2016 01:59 PM
Is it possible to call the server code from the client controller? I want to be able to do this so I can poll in widget I'm creating. I know I can do this by polling a REST service, but I'd rather use what's within the widget if possible.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2016 02:44 PM
Hi Dan,
Check out this doc: Client and server scripting
From the Client Controller you can use c.server.update() (assuming you are using the controller as syntax). This will then call the Server Script in the widget. Of course the issue here is that the Server Script is then called both on request and again on AJAX calls. To distinguish, add an if check in the Server Script for the input variable which contains the AJAX data.
Server Script Example
if (input) {
// AJAX from c.server.update()
}
else {
// Initial load
}
If you check existing widgets, you will find this if (input) pattern.
Kind regards,
Travis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 11:07 PM
I know this is old, but for anyone that is looking, this other post answers this question.
server.update() vs server.get()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 05:55 PM
Thankyou for this. I am new to service portal and this just saved me !