SP widget: get data from table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2017 04:41 AM
Hi,
in my widget I need to load all records - 2 fields (e.g. name, surname) from table (e.g. Person)
My client script:
c.server.get({
action: "getUsers"
}).then(function(response) {
console.log(response);
});
My server script:
if (input && input.action == 'getUsers'){
var gr = new GlideRecord('x_111111_person');
gr.initialize();
// What shoud be here?
}
So what should be in a server script starting from line #4 in order to get all records from current table - I need to get 2 fields: "name" and "surname" ?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2017 04:50 AM
HI Ivan to get value you can use this in your code.
var newArr = [];
var gr = new GlideRecord('x_111111_person');
gr.query();
while (gr.next())
{
var icSet = {};
icSet.name= gr.getDisplayValue('name');
icSet.surname= gr.getValue('surname');
newArr.push(icSet);
}
Thanks,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2017 06:09 AM
And how can I pass response back to Client Script?
in my Client Script above in line #4
console.log(response);
doesn't fire.