How to pass value from client controller to server controller in portal widget ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-06-2024 05:57 AM
This is not working. Getting undefined in server script
Client code
api.controller = function($scope) { /* widget controller */ var c = this; this.show = function(i) { c.data.i = 'this is my short description'; c.server.get().then(function() { c.data = {} }); } } //};
Server code
(function() { gs.info("client="+input.i); })();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-06-2024 06:01 AM
@Snehal13 : Please refer the below community article. It has good examples along with script examples that will help you.
https://www.servicenow.com/community/developer-forum/how-to-send-data-from-client-controller-to-serv...
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-06-2024 06:07 AM
None of the solutions worked. Already tried that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-06-2024 06:31 AM
Hello @Snehal13 ,
Please use below codes on client side and server side
Client side code:
api.controller = function($scope) {
/* widget controller */
var c = this;
this.show = function(i) {
c.data.i = 'this is my short description';
// passing the string value through I paramter to string side
c.server.update() // to trigger server script
}
})
Server side code:
if(input)
{
gs.addInfoMessage(input.i)
// this is my short description will come in message
}
If it helps click on like icon and mark it as accepted