- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2019 02:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2019 04:05 AM
Hi,
Do you want to copy all records or some of them?
if you want all of them
then write code like
var gr=new GlideRecord('Live feed message table name');
gr.query();
//gs.print(gr.getRowCount());
while(gr.next())
{
var cs=new GlideRecord('Target table name');
cs.initialize();
//as like bellow you can take values from gr and initialize them
//make sure that field type shoulb be compatible
// cs.u_item=gr.sys_id;
// cs.u_stockroom='ffec3762dba71f004b6cf3561d9619c6';
// cs.u_stock_number=100;
// cs.u_stock_limit=10;
cs.insert();
}
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2019 03:02 AM
Hello Vijay
i'll assume both table has the same structure?
You can query with glideRecord the "source" table and in a while loop insert the rows in the "target" table.
Maybe this is not the more efficient way (depend the number of rows) but works
Ariel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2019 04:05 AM
Hi,
Do you want to copy all records or some of them?
if you want all of them
then write code like
var gr=new GlideRecord('Live feed message table name');
gr.query();
//gs.print(gr.getRowCount());
while(gr.next())
{
var cs=new GlideRecord('Target table name');
cs.initialize();
//as like bellow you can take values from gr and initialize them
//make sure that field type shoulb be compatible
// cs.u_item=gr.sys_id;
// cs.u_stockroom='ffec3762dba71f004b6cf3561d9619c6';
// cs.u_stock_number=100;
// cs.u_stock_limit=10;
cs.insert();
}
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2019 05:09 AM
Something similar to this
//Query the source table
var grSource = new GlideRecord("your_source_table");
grSource.addQuery("field1", "value1"); //to query the source table. If not (all the rows) comment this line
grSource.query();
while (grSource.next()) {
//Insert into target table
var grTarget = new GlideRecord("your_target_table");
grTarget.initialize();
//Populate the target fields
grTarget.field1 = grSource.field1;
grTarget.field2 = grSource.field2;
grTarget.insert();
}
Please, mark correct, useful or bookmark if I helped you
Thanks
Ariel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2021 03:00 AM
What if i dont want to copy all the fields on by one,
So instead of ,
grTarget.field1 = grSource.field1;
grTarget.field2 = grSource.field2;
can i run a loop or something to copy all fields?
-Neil