How can I pass a variable from client script to server script in a service portal widget?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 05:32 AM
I have built a query on client side, I want to use it on the server side querying process, is there a way to just pass that variable to server script?
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 05:34 AM
Hi,
please check the following thread:
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thank you
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 05:40 AM
The only solutions I found only set a parameter for a function. I want to get a string variable from client script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 05:44 AM
You can use c.server.update to send the data to server as mentioned below.
function($scope) {
var c = this;
c.data.abc='Any Name';
c.update = function() {
c.server.update().then(function (response) {
c.data = {};
})
}
}
Server side you can use
if(input)
{
gs.log(input.abc);
}
else
{
//Code for intial load
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 07:47 AM
Hi Marton,
First of all , its very easy to pass any values from Client-Script to Server-Side , i will show to you how you can do that in a simple way :
* Example
( Client Side ) :
c.data.ThisIsYourVariable = false;
if ( 3 > 2 ){
c.data.ThisIsYourVariable = true ; // Use C.Data.X to Make your variable ready to pass to server-side
}
( Server Side ) :
console.log(input.x); // this console.log will print true
THAT ALL 🙂 BEST OF LUCK