Client side GlideRecord callback not working

snoozer
Mega Guru

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:

https://www.servicenow.com/docs/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/...

 

Any help or thoughts would be appreciated. Thanks.

1 ACCEPTED SOLUTION

snoozer
Mega Guru

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.

View solution in original post

10 REPLIES 10

snoozer
Mega Guru

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.