c.server.update() doesn't work and i don't know why

anchor
Kilo Contributor

My client controller capture event from another widget and update the server by c.server.update() but it doesn't work,

the server side has no refresh and no output.

Client side(call c.server.update()):

find_real_file.png

server side:

find_real_file.png

(No 'kpi data' and 'submit' as console output )

It's urgency and need your kind kelp!! 

6 REPLIES 6

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

 

At server side can you use gs.log instead of console.log.


Thanks,
Ashutosh Munot

SaiRaviKiran Ak
Giga Guru

Hi,

 

Can you try removing console.log('kpi data') from top line and add it after if  ?

Vijay Pawar3
Tera Contributor

Hello,

try something like this :

c.data.submitdata= 'test data';

var unregister = $scope.$on('test event',c.server.update().then(function(response){
            // remaining code;
        }));

 

mark this answer as correct if it helps.

ChrisBurks
Mega Sage

I think what may be missing is assigning the new values to the necessary variable.

As you are aware c.server.update() updates the server side via the input object but what it doesn't do automatically is reset the data object. For example if a variable is being used on the client side c.data.needUpdating or even just data.needUpdating (set in the html template) then that variable would need to be updated in the input object set in the server side or in the promise of c.server.update();

 

Examples: Updating variable server side:

if(input && input.something){
    data.needUpdating =  someFunc(input.something)
}

function someFunc(inp){
     //  do some stuff with inp
        ... using inp for something 
  return answer;
}

 

 

Or updating via promise

 

Server side

 

if(input && input.something){
    data.placeholder =  someFunc(input.something)
}

function someFunc(inp){
     //  do some stuff with inp
        ... using inp for something 
  return answer;
}

client side promise

$scope.someFunc = function (){
      c.data.something = "something";
      c.server.update().then(function(resp){
                 c.data.needUpdating = resp.placeholder;
       });
}