- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2023 12:20 AM
Hi Everyone,
I have an requirement that, I need to send the data from server side to HTML check box. Based on server side data, i need to show the checkbox field either true or false. I have tried with using below data and unable to fetch and show the data in service portal. Please check below code and correct me.
HTML Code:
<div >
<label><input type="checkbox" ng-model="chkbx" ng-checked="data.u_customfield" ng-click="checkNotify(chkbx)" ng-checked="false"> testing</label>
</div>
Server side:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2023 01:28 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2023 12:27 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2023 12:48 AM
Hi Peter,
Thanks for your response. Please find below client script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2023 01:28 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2023 12:34 AM
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