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.

fix script to copy data except one field

aagman4
Tera Contributor

Suppose I have a table 'cmdb_ci_business_app', I wanted to create duplicate of all records present in this table except one field 'short_description'.

 

I am trying below script and it is not populating data for technology_stack and it_application_owner fields as existing records

 

var gr = new GlideRecord("cmdb_ci_business_app");
gr.query();
while(gr.next()) {
var newGr = new GlideRecord("cmdb_ci_business_app");
newGr.initialize();
newGr.technology_stack = gr.technology_stack.toStrin();
newGr.it_application_owner = gr.it_application_owner.toStrin();
newGr.short_description='Tash Dubrovska';
newGr.insert();
}

 

Please help me on this.

Thanks!

1 REPLY 1

Mohit_Gupta
Tera Guru
Tera Guru

Hi @aagman4 ,

 

Please try below article to resolve your issue:- 

Solved: Copy record into the same table with new sys_id - ServiceNow Community

 

I hope this helps 

Please mark my answer correct if this helps you 

Thanks

Mohit