- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 09:41 PM
I have a super simple sample that I would like to update when a button is clicked, below is the table:
this is the code that populates the table::
```
/*
fetch data that will be displayed on the html on
first render
*/
var gUser = new GlideRecord('sys_user');
gUser.addEncodedQuery('company=81fca4cbac1d55eb355b4b6db0e3c80f');
gUser.orderBy('user_name');
gUser.query();
while( gUser.next() ){
var obj ={};
obj.userID = gUser.getValue('user_name');
obj.name = gUser.getValue('first_name');
obj.email = gUser.getValue('email');
obj.lastName = 'empty';
data.table.list.push(obj);
}
```
when the user clicks one of the green buttons, the following client script sends that information to the server script::
```
$scope.showName = function (name){
//alert('The name is : '+name);
c.data.answer = name;
c.server.update()
}
```
this is where the issue begins, I want to update the html table, but I cant seem to get this to work!
the code below updates the table that is displayed on the client side. but the widget does not refresh
```
/*
If there is an input, update the data obj with
last name
*/
if (input) {
var gr = new GlideRecord('sys_user');
if(gr.get('user_name', input.answer)){
for ( var row in data.table.list ){
if(data.table.list[row].userID==input.answer) {
data.table.list[row].lasName = gr.getValue('last_name');
gs.addErrorMessage(data.table.list[row].lasName);
}
}
}
}
```
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2022 10:32 AM
Hi Juan,
Is this still an issue? I noticed from the code you posted that the server script
data.table.list[row].lasName = gr.getValue('last_name');
has a typo with the lastName property. From this code sample
obj.lastName = 'empty';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2022 10:32 AM
Hi Juan,
Is this still an issue? I noticed from the code you posted that the server script
data.table.list[row].lasName = gr.getValue('last_name');
has a typo with the lastName property. From this code sample
obj.lastName = 'empty';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2022 10:55 AM
yeah i cought that after posting the question last night.
good eye!