GlideRecord Returning null for non-empty fields

kelseyn
Kilo Contributor

I'm writing a business rule that queries a custom table and finds all records that match certain criteria that I will set up. However, when I run tests to get the value of specific fields within the record, the system returns null. It is registering the records, though. It is returning the correct row count, just not recognizing any of the column names. The table is readable from all application scopes, and I have the correct role.

Here is the bare bones code I'm using to get the first piece I need. I have tried just logging the field with 'gs.info(gr.intswraddr1)' and 'gs.info(intswraddr1)', and got the same result:

myFunction();

function myFunction() {

  var gr = new GlideRecord('x_ciofm_solid_wast_address'); //create glide record to find all addresses on the updated street

  //var queryString = "intstrtkey.sys_id=018fe3123736220064a39da543990e38";

  //gr.addEncodedQuery(queryString); //testing with specific street

  gr.query();

    gs.info('count : {0}', gr.getRowCount());

  var count = 0;

  while((gr.next) && (count1 < 10)) {

  gs.info(gr.getValue('intswraddr1'));

  count = count + 1;

  }

gs.info('swis count 2 {0}', count1);

}

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee

I think your issue may be in the iterating through the records, why don't you try substituting these 4 lines:



  while(gr.next()) {


  gs.info(gr.getValue('intswraddr1'));


  count = count + 1;


  }


View solution in original post

2 REPLIES 2

Brad Tilton
ServiceNow Employee

I think your issue may be in the iterating through the records, why don't you try substituting these 4 lines:



  while(gr.next()) {


  gs.info(gr.getValue('intswraddr1'));


  count = count + 1;


  }


That solved it, nice catch!