- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 08:22 AM
I'm working on a UI page. I need to load some values from a table into a slushbucket for users to choose. The problem is that in the callback function, I can not access the GlideRecord object. Here is my code:
function _getAMFEntriesForSlush()
{
var amfGR = new GlideRecord('u_amf_entry');
amfGR.query(_amfCallBack);
}
function _amfCallBack(amfGR)
{
alert("hi" + amfGR); // I get this alert
alert("hi " + amfGR.getRowCount()); // I do not get this alert
// none of the following happens
while (amfGR.next())
{
var amfName = amfGR.getValue('u_name');
var amfID = amfGR.getValue('sys_id');
amf_slush.addLeftChoice(amfID, amfName);
}
}
The code to populate the slushbucket never gets run. I put in some alerts to see where the code is failing. I get that first alert, and it says "hi [object Object]". I do not get the second alert, which tells me there's a problem with referencing the GlideRecord object. Why?
What's really frustrating is that I have done this exact thing before and it works perfectly. I copied that code to write this. The other code works, but this doesn't.
Here's a the reference I used about client side GlideRecords:
Any help or thoughts would be appreciated. Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 12:25 PM
I ended up creating a whole new UI Page and copying the code into the new page. It works with no changes. No idea why the previous page didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 08:55 AM
Hello @snoozer
Found this from the document you have referred:
Try modifying the script as shown in the highlighted part.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 09:44 AM
The row count is not what I'm looking for here. That's just something I tried to output to se where the code is breaking down.
What I want is for the lines following the "// none of the following happen" comment to run. They do not get run at the moment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 09:02 AM
Hi @snoozer ,
getRowCount() Method Doesn't exist in Client side GlideRecord Class.
that code could be throwing an error at the getRowCount() method.
just comment that line and test the code.
if you want to see the row count you can use GlideAjax or use a temporary count variable and increment it inside the while loop.
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 09:41 AM
I don't really care about the rowCount. I just put that in there to see if accessing something from the GlideRecord was throwing the error. The code still doesn't work when the line is commented out.