Peter Bodelier
Giga Sage

Hi @suresh91 

 

Please add your client script as well.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Hi Peter,

 

Thanks for your response. Please find below client script

$scope.checkNotify = function(val) {
        alert("test" + val);
        $scope.data.u_customfield = val;
        $scope.server.update().then(function() {
            $scope.data.u_customfield = val;
        });
But i have used the above code for update data in table. Do i need to change or add anything?

    

Hi @suresh91 

 

This should work:

 

HTML:

<div >
<label><input type="checkbox" ng-model="chkbx" ng-checked="data.u_customfield" ng-click="c.checkNotify(chkbx)"> testing</label>
</div>

 

Client:

api.controller=function($scope) {
	/* widget controller */
	var c = this;


	c.checkNotify = function(val) {


		c.data.action = "getField";
		c.data.value =  val;


		alert("test Before " + val);

		c.server.update().then(function(response){
			alert("test After " + response.u_customfield);

		})
	}
}

Server:

(function() {

	if (input){
		if (input.action == "getField"){
			var gr_notify = new GlideRecord('sys_user');
			gr_notify.addQuery('sys_id', gs.getUserID());
			gr_notify.query();
			if(gr_notify.next())
			{
				gs.addInfoMessage(gr_notify.getDisplayValue())
				data.u_customfield = gr_notify.u_customfield;
				return data;
			}
		}
	}

})();

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

Utpal Dutta
Tera Guru

Hi Suresh,

I see that you are using ng-checked 2 times. One with server value and another that you're making it false. Please remove the other one which is making in false and see if it is working.

 

Please mark my answer correct if it does.

 

Thanks,

Utpal

 

Hi Dutta,

 

Thanks for your response.

I did the change but still not getting value. I tried to add info message like below and it showing value in portal

gs.addInfoMessage("testing record value---------->"+data.u_customfield);