Service Portal: Client Side Data to Server Side

Dhruv Chandan
Giga Guru

Hi All,

I've created a custom field using HTML and now i want to get the value being input in that field towards the server side in Service Portal.

HTML Part:-

<div>

  <img ng-src="{{::c.data.logo}}" />

  <a href="?id={{::c.data.homepage}}">Click here to go home</a>

</div>

<div>Enter your Last name:

<input type="text" ng-model="c.data.lastname" id="LN" ng-change="c.displayNew()"/>

<h2>{{ c.data.messageNew }}</h2>

</div>

Client Side Part:-

function() {
var c = this;
c.displayNew = function(){
c.data.messageNew = (c.data.lastname) ? 'Hello ' + c.data.lastname + '!' : '';
}
c.display();
c.server.update();

}

Server Side part:-

(function() {

  /* populate the 'data' object */

  /* e.g., data.table = $sp.getValue('table'); */

  console.log("Server Side"+input);

  var portalGr = $sp.getPortalRecord();

  console.log("Server Side"+portalGr);

})();

Any idea how to get the "Last Name" which is being input to the server side for further validations.

Any help is appreciated.

Regards,

Dhruv Chandan

1 ACCEPTED SOLUTION

Hi Dhruv,



You're close here. When using server.update() the data object is represented by the input object, so you would typically do something like this on the server:



if (input) {


      console.log("Server Side: " + input.lastname);


}



You don't need to write input.data, and service portal is unique in that it lets you use console.log() on both the client and server side script areas.


View solution in original post

6 REPLIES 6

Hi Dhruv,



You're close here. When using server.update() the data object is represented by the input object, so you would typically do something like this on the server:



if (input) {


      console.log("Server Side: " + input.lastname);


}



You don't need to write input.data, and service portal is unique in that it lets you use console.log() on both the client and server side script areas.


Hi Brad,



Thanks man it worked !



Regards,


Dhruv Chandan