- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 11:18 PM
Hi all.Am working on service portal,trying to pass values from client side to server side. Tried the following code but am getting nothing on console log.
Client side:
function() {
/* widget controller */
var c = this;
c.data.val='abcdefg';
c.update = function() {
c.server.update().then(function (response) {
c.data = {};
})
}
}
Server side:
(function() {
if(input)
{
console.log(input.val);
}
})();
whats wrong with my code?Please advice!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 11:34 PM
Try client script as beloow,
function() {
/* widget controller */
var c = this;
c.server.get({
val:'abcdefg'
}).then(function(r){
});
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 12:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 11:35 PM
Hi sana,
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 initial load
}
NOTE: Mark correct or helpful if it helps you.
Warm Regards,
Raj patel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 12:22 AM
Hi Sana,
Please write below code:-
HTML PART:-
<div>
<!-- your widget template -->
<input type="submit" value="Insert" ng-click="c.update()">
</div>
--------------------------------------------------------------------------------------------
Client Script:-
function() {
/* widget controller */
var c = this;
c.data.val="Testing";
c.update = function() {
c.data.action = "Test"
c.server.update().then(function (response) {
c.data = {};
})
}
}
----------------------------------------------------------------------------------------------------------
Server Script:-
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if(input.action == "Test"){
gs.addInfoMessage(input.val);
}
})();
Regards
PKG