Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Copy field value from one field to another in same table

Community Alums
Not applicable

Hi all,

I'm facing a trouble while trying to copy the field values -Basically we have a custom table with few task types and there are two fields present in the Task A ,I need to copy the fields values from Task A type to  the fields under the Task B type. Can anyone help me out with this please?

8 REPLIES 8

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Something like this will work

var gr = new GlideRecord('<your table>');
gr.addQuery('add query to filter records you want to copy the fields for');
gr.query();
while(gr.next())
{
current.<target field name> = current.<source field name> ;
current.<target field name> = current.<source field name> ;
current.update();
}
-Anurag

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Can you paste some screenshot it would be easier to assist you.

 

Thanks.

Community Alums
Not applicable

SubhikshaNaray_0-1667905590774.png

 

Why are you doing this on a BR and not via fix script/backgroup script?

Is this a one time copy or something that you do as part of your process?

-Anurag