Service Now Portal Get Response from server side to client controller

ngo
Kilo Contributor

Hey Folks,

I am trying to call server script to execute via c.server.update which is working perfectly but I am unable to use RESPONSE in c.server.update().then(function(response) parameter

I have returned data ; in server code

and writing

Server Side

if (sys_id) {

  data.sys_id = sys_id;

  data.status = "success";

  gs.log("Logs "+data.sys_id + data.status);

  //data.message = gs.getMessage("Your request has been submitted and is pending review. You will receive an email when your request is processed.");

  } else {

  data.status = "error";

  }

  return data;

Client Side

if (response.status == 'success') {

  spUtil.addInfoMessage = ('The Request has been submitted');

  }

Log is coming but info message is not getting displayed

Kindly help

Thanks & Regards

Nitish Goel

4 REPLIES 4

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

try this:


c.server.update().then(function(response) {


if (c.data.status == 'success') {


  spUtil.addInfoMessage = ('The Request has been submitted');


  }


});



//Göran


Hi Goran



Already tried that but still not working



Thanks


Nitish Goel


Why don't you just display the info message on the server instead using gs.addInfoMessage('The Request has been submitted').


ngo
Kilo Contributor

Hi Nathan



First of all thanks for your amazing work on service now portal


Yes that would work but I will have some further enhancements in coming future from client which will be based on the response received from the server's end


I thought since it is a param in c.update.server method so there should not be any problem in receiving one



Thanks


Nitish Goel