How do I get the current record in a glideRecord query?

lightblu
Mega Expert

Hi,

I would like to know how to get the current element/record in a glideRecord query.

Here is my current script:

find_real_file.png

The

gr.x_prgm_red_team_te_u_integer_1 -= 1;

part is decrementing all the records in gr which get returned from the query.

I want something like:

while(gr.hasNext()){

     

        //conditional

        if(gr.peekNext().x_prgm_red_team_te_u_integer_1 > currOrder){

                  //decrement only the specific record gr.next is on, not every record in gr

                  gr.next().x_prgm_red_team_te_u_integer_1 -= 1;

        }

}

hence my conditional.

1 ACCEPTED SOLUTION

lightblu
Mega Expert

//grab the other records in the table x_prgm_red_team_test_app_request


var gr= new GlideRecord('x_prgm_red_team_test_app_request');


gr.addQuery('sys_id','!=',current.getValue('sys_id'));


gr.addQuery('state','1');


gr.query();



//decrement the orders for each of the other records if it is > currOrder


while(gr.next()){


  //only decrement the order for the record if it is > currOrder


  if(gr.x_prgm_red_team_te_u_integer_1 > current.x_prgm_red_team_te_u_integer_1){


    gr.x_prgm_red_team_te_u_integer_1 -= 1; //decrement


    gr.update();


  }


}




//reset the priority order for the current record to blank


current.x_prgm_red_team_te_u_integer_1 = '';


View solution in original post

5 REPLIES 5

lightblu
Mega Expert

//grab the other records in the table x_prgm_red_team_test_app_request


var gr= new GlideRecord('x_prgm_red_team_test_app_request');


gr.addQuery('sys_id','!=',current.getValue('sys_id'));


gr.addQuery('state','1');


gr.query();



//decrement the orders for each of the other records if it is > currOrder


while(gr.next()){


  //only decrement the order for the record if it is > currOrder


  if(gr.x_prgm_red_team_te_u_integer_1 > current.x_prgm_red_team_te_u_integer_1){


    gr.x_prgm_red_team_te_u_integer_1 -= 1; //decrement


    gr.update();


  }


}




//reset the priority order for the current record to blank


current.x_prgm_red_team_te_u_integer_1 = '';