- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2016 01:55 PM
Hello,
I am new to SN and have been trying to get a GlideRecord to display as an alert using an HTML Widget on a Service Portal widget.
I was successfully able to load the record, but I get an error message on my console that tells me that I need to use a callback function. I have not been able to correctly create this callback function.
This is my script:
function text() {
var res = new GlideRecord('incident');
res.addQuery('number', 'INC0000001');
res.query(getCallback);
}
function getCallback(res) {
if(res.next()){
var shortDescription = res.short_description.getDisplayValue();
alert(shortDescription);
} else {
console.log("not working")
}
}
text();
I get this error:
Uncaught (in promise) TypeError: Cannot read property 'records' of undefined(…)
at js_includes_sp.jsx?v=04-21-2016_1541&lp=Thu_May_19_12_55_41_PDT_2016&c=2_42:64344
What am I doing wrong?
Thanks for the help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2016 08:24 AM
I would suggest you do your GlideRecord query using server script. Widgets in Service Portal are run as an Angular directive (scoped) so I'm not sure if some of the typical ServiceNow client scripts will run as expected.
Take a look at the widget "Hello World 3", it shows how to call the server script from the client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2016 02:19 PM
Excellent. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2016 04:16 AM
Hello
where is HEllo world 3 widget?
stephane