pass value from server to client controller widget

arey yaar
Giga Guru

need to pass the value from server to client

client controller
	c.uiAction = function(sysid) {
	c.data.delegateid=sysid;
			
c.server.update();
}


Server:

data.delegatename="";
		 if (input && input.action) {
	 var action = input.action;

	 if (data.table == 'sys_user_delegate') {

		 var delremove=new GlideRecord(data.table)
		 delremove.addQuery('sys_id',input.delegateid);
		 delremove.query();
		 if(delremove.next())
			 {		
				 console.log(delremove.delegate+"deleted user");
				 data.delegatename=delremove.delegate;
				 if (action == 'remove') 
				 {
					 
				//delremove.deleteRecord();
				 }
			 }
	 }
	 }
	console.log(data.delegatename+"goo nn///")



I need to pass data.delegatename to client controller.

6 REPLIES 6

Brad Tilton
ServiceNow Employee
ServiceNow Employee

It looks like you're already passing it, you just need to access it from the client with c.data.delegatename

Im not able to get the value from server by trying the below script..

in server im able to get the value..

 

	c.server.update().then(function(){
       alert(JSON.stringify(c.data.delegatename));
    });

 

find_real_file.png

Lansford Hazel
Giga Expert

data.delegatename should be available with the following syntax:

HTML:

<p>{ {data.delegatename} }</p>

Client Script:

var delegatename = c.data.delegatename;

 

If you would like to use data.delegatename immediately after it is retrieved from the server you can use the following:

c.uiAction = function(sysid) {
    c.data.delegateid = sysid;
			
    c.server.update().then(function(){
        doSomeThing(c.data.delegatename);
    });
}

 

Im not able to get the value from server by trying the below script..

in server im able to get the value..

 

c.server.update().then(function(){
       alert(JSON.stringify(c.data.delegatename));
    });

find_real_file.png