Forwarding a multi-row GlideRecord object

When passing multiple rows from a GlideRecord object, pass the query used to generate the GlideRecord.

In this example, the sending activity writes enough information about a GlideRecord object to the scratchpad for the follow-up activity to recreate the GlideRecord object.

function passJoesIncidentsToProcessingActivity() {
    // first find Joe User
    var joeUser = new GlideRecord('sys_user');
    if (!joeUser.get('name', 'Joe User')) {
        workflow.debug('User: Joe User not found');
    // read the row into a glide record.
    var grIncident = new GlideRecord('incident');
    grIncident.addQuery('caller', joeUser.getUniqueValue() );
    sendQueryGR('joesIncidents', grIncident);
// send any filtered GR to another activity via scratchapd
function sendQueryGr(variableName, gr) {
    workflow.scratchpad[variableName] = grDescriptor(gr);
function grDescriptor(gr) {
    return {
	 sys_id:  gr.getUniqueValue(),   // curent row, if applicable
	  table:  gr.getTableName(),
	  query:  gr.getEncodedQuery()

The follow-up activity then duplicates the original GlideRecord query using the scratchpad values.

// Re-query in the follow-up activity:
var gr = reloadQuery('joesIncidents');
function reloadQuery(variableName) {
    var grDescriptor = workflow.scratchpad[variableName];
    var gr = new GlideRecord(grDescriptor.table);
    // [Optional] seek to the same row
    while ( {
    	if (gr.getUniqueValue() == grDescriptor.sys_id)
    workflow.debug(grDescriptor.table + ':' + grDescriptor.sys_id + ' - record not found');