Paginated GlideRecord Utility (Free tool and how-to!)

Tim Woodruff
Mega Guru

Hey folks,

I've just written a new article over at http://www.snprotips.com about how to get a paginated GlideRecord. That is, how to get GlideRecords in a query, on a page-by-page basis (specifying the number of records per "page") for the purposes of handling a larger subset of records in a GlideRecord query or scripted REST API, or for creating and populating pages of records of one sort of another inside of a UI page, or anything else like that.

There's a whole huge detailed article on exactly how it works line-by-line, over here:

SN Pro Tips — GlideRecord Pagination - Page through your GlideRecord query  

And here's the page where you can see usage examples, API documentation, and a download link for this tool!

SN Pro Tips — Paginated GlideRecord Utility

If you really like the tool, I humbly welcome you also to check our our other articles at the bottom, and subscribe! 🙂

Feel free to post any questions below.

2 REPLIES 2

Deepak Ingale1
Mega Sage

Great to see another cool article 🙂


Community Alums
Not applicable

Hi Nice Article.. I am trying to using this in Scripted REST . I need 20 incidents per page and i am receiving an error in callback function . Request you to help on the same.


function myCallBack(){



  var queryString1 = 'u_callerLIKEjavascript: gs.getUser().getFullName()^ORopened_byLIKEjavascript: gs.getUser().getFullName()^ORassigned_toLIKEjavascript: gs.getUser().getFullName()';


var queryString2 = 'u_callerLIKEjavascript: gs.getUser().getFullName()^ORopened_byLIKEjavascript: gs.getUser().getFullName()';


var queryString3 = 'u_callerLIKEjavascript: gs.getUser().getFullName()^ORopened_byLIKEjavascript: gs.getUser().getFullName()';


}



var pgr =new PageGlideRecord('table',off);


  pgr.setCallBack(myCallBack);


  while (pgr.nextPage()) {


  if(user_type == 'Technician')


{


pgr.addEncodedQuery(queryString1);


}


if(user_type == 'End User')


{


pgr.addEncodedQuery(queryString2);


}


if(user_type == 'VIP')


{


pgr.addEncodedQuery(queryString3);


}


pgr.orderByDesc('sys_updated_on');


pgr.query();


var result = {};


result.number = pgr.number.getDisplayValue();


result.location = pgr.location.getDisplayValue();


result.priority = pgr.priority.getDisplayValue();


result.opened_at = pgr.opened_at.getDisplayValue();


result.short_description = pgr.short_description.getDisplayValue();


result.description = pgr.description.getDisplayValue();


result.state = pgr.state.getDisplayValue();


result.cmdb_ci = pgr.cmdb_ci.getDisplayValue();


result.requested_for = pgr.requested_for.getDisplayValue();


result.close_notes = pgr.close_notes.getDisplayValue();


result.business_service = pgr.business_service.getDisplayValue();


result.closed_at = pgr.closed_at.getDisplayValue();


result.stage = pgr.stage.getDisplayValue();


result.comments_and_work_notes = pgr.comments_and_work_notes.getDisplayValue();


result.sys_id = pgr.sys_id.getDisplayValue();


result.sys_updated_by = pgr.sys_updated_by.getDisplayValue();


result.sys_created_by = pgr.sys_created_by.getDisplayValue();


result.sys_created_on = pgr.sys_created_on.getDisplayValue();


result.assigned_to = pgr.assigned_to.getDisplayValue();


result.opened_by = pgr.opened_by.getDisplayValue();


result.assignment_group = pgr.assignment_group.getDisplayValue();


result.contact_type = pgr.contact_type.getDisplayValue();


result.Phone = pgr.u_mobile_phone.getDisplayValue();


result.impact = pgr.impact.getDisplayValue();


result.urgency = pgr.urgency.getDisplayValue();


result.subcategory = pgr.u_subcategory.getDisplayValue();


result.u_feedback_description = pgr.u_feedback_description.getDisplayValue();


result.u_feedback_value = pgr.u_feedback_value.getDisplayValue();


result.u_feedback_status = pgr.u_feedback_status.getDisplayValue();


result.u_impacted_application = pgr.u_impacted_application.getDisplayValue();


result.category = pgr.u_category.getDisplayValue();


result_arr.push(result);


}



This is my call back function. I am receiving an error that cannot be found . Can u tell me where i am doing the mistake??



This is the error i am getting.


{
  "error": {
  "detail": "",
  "message": "Invalid or no callback function specified when calling setCallback in PagedGlideRecord (sys_script_include.edeb6a9adb4222001a22773ebf9619fb; line 82)"
  },
  "status": "failure"
}