Pass variable value from Client Controller to Server in widget

Maxwell3
Kilo Guru

I am getting the value of the content of a field in a Record Producer using a widget.

I am trying to pass that value from the Client Controller into the Server side of the Widget.

I have an alert pop-up, and it seems to display the desired value from the field.

The Logs return 'undefined'.

I eventually want to use that field value and query a record from a table using that sys_id, but I can't get that sys_id to pass from the controller to the server.

 

CLIENT CONTROLLER:

api.controller=function($scope) {
/* widget controller */
var c = this;
c.uiAction = function(action){
c.data.action = action;
var i=$scope.page.g_form.getValue('field_name');
alert("The value is "+i);
c.server.update().then(function(){
c.data.action = undefined;
c.data.i = i;
})
}
};

 

SERVER:

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if (input){
gs.info("fieldName value is "+input.i); <---Returning undefined in the logs
}
})();

1 ACCEPTED SOLUTION

SVimes
Kilo Sage

Try moving c.data.i to before c.server.update(). I don't see that it needs to be defined after c.server.update and I'm not seeing it work that way when I test it in my PDI.

Sable Vimes - CSA

View solution in original post

1 REPLY 1

SVimes
Kilo Sage

Try moving c.data.i to before c.server.update(). I don't see that it needs to be defined after c.server.update and I'm not seeing it work that way when I test it in my PDI.

Sable Vimes - CSA