How to copy List field from one table to another.

cc11
Tera Contributor

Hi,

I am running the query below to copy date from source table into target table.

All columns are getting copied except the List field.

Looking for help,

var gr = new GlideRecord('u_source_table');
gr.addNotNullQuery('u_format');
gr.setLimit(3);
gr.query();

while(gr.next()){
var gr1 = new GlideRecord('x_target_table'); 
gr1.initialize();
gr1.name=gr.u_name;
gr1.u_notify_on_expiration=gr.u_notify_on_expiration; // LIST FIELD NOT COPYING
gr1.server=gr.u_server_name;
gr1.insert();
}
1 ACCEPTED SOLUTION

Shweta KHAJAPUR
Tera Guru

Hi,

Your code is working fine for me. Check field name once. Add some info/log messages just after while as below,

gs.addInfoMessage(gr.u_notify_on_expiration);

OR

gs.print(gr.u_notify_on_expiration);

 

Regards,

Shweta K

View solution in original post

11 REPLIES 11

Thanks Bhawana,

 

This too helped me in a different script.

 

Regards,

Yogesh

Ujjawal Vishnoi
Mega Sage
Mega Sage

Hi,

Can you please share the field type of the source and target field.

 

Regards

Ujjawal

Sure Ujjawal,

The field type is 'glide_list' (both source and target fields).

 

Thank you,

Yogesh

Shweta KHAJAPUR
Tera Guru

Hi,

Your code is working fine for me. Check field name once. Add some info/log messages just after while as below,

gs.addInfoMessage(gr.u_notify_on_expiration);

OR

gs.print(gr.u_notify_on_expiration);

 

Regards,

Shweta K

The field name was incorrect. My custom Target table was a child table of Task and I was using the watch_list field (the display name was overridden and I was using the same). Changed it to 'watch_list' and it worked.