Update records from Scripts Background

Sravanthi10
Tera Contributor

Hello guys,

There are more than 500 records in a table. Based on Assigned to field's value I want to update User ID field for all those. So in scripts background I have written like this but no success.

var gr = new GlideRecord('table_name');

gr.addEncodedQuery(',,,,,,,,,');

gr.query();

while(gr.next()){

gr.u_user_id = gr.assigned_to.user_name;

}

 

Please help here

 

 

Regards,

Sravanthi

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Sravanthi, 

In the while loop, you will need to do gr.update() for each of those records. So like: 

while(gr.next()){

gr.u_user_id = gr.assigned_to.user_name;
gr.update()

}

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

Hi Sravanthi, 

In the while loop, you will need to do gr.update() for each of those records. So like: 

while(gr.next()){

gr.u_user_id = gr.assigned_to.user_name;
gr.update()

}

Thanks Mike. Happy Weekend 🙂

 

 

Regards,

Sravanthi