- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017 11:14 PM
Hi Experts,
I want to copy some date value from another table in bulk. i want to set a value for almost 4k records.
tried with,
1. rec.u_test_cancel_date = rec.u_project_id.end_date.getGlideObject();
2. rec.u_test_cancel_date = rec.u_project_id.end_date.getDisplayValue();
3. rec.u_test_cancel_date.setValue(rec.u_project_id.end_date);
but when i run this for bulk update in background script it will run for only one record and update only one record.
Do we have any other way to resolve this as it is not able to update all the records in a single run.
Regards,
Amol Bavaskar.
+91-9405444404
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017 11:25 PM
Hi Julian,
Here is the script :
var rec = new GlideRecord('u_test_plan');
rec.addQuery('u_request_status','canceled');
rec.addQuery('u_test_cancel_date','');
//rec.setLimit(3);
rec.query();
gs.print("row :: "+rec.getRowCount());
while(rec.next()) {
rec.u_test_cancel_date = rec.u_project_id.end_date;
gs.print('Project_ID :: '+rec.u_project_id);
gs.print('End Date :: '+rec.u_project_id.end_date);
rec.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017 11:25 PM
Hi Amol,
You can update Data one table to Another table using Background Script.
First map that two table and Use "while" condition it will update bulk data.
Pls HIT/like correct this is halpful..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017 11:36 PM
Hi Pavan,
I used while loop i just have posted my code
please check
Regards,
Amol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017 11:36 PM
Here is the script :
var rec = new GlideRecord('u_test_plan');
rec.addQuery('u_request_status','canceled');
rec.addQuery('u_test_cancel_date','');
//rec.setLimit(3);
rec.query();
gs.print("row :: "+rec.getRowCount());
while(rec.next()) {
rec.u_test_cancel_date = rec.u_project_id.end_date;
gs.print('Project_ID :: '+rec.u_project_id);
gs.print('End Date :: '+rec.u_project_id.end_date);
rec.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2017 12:02 AM
Hi Amol,
Are you trying to get field value from one table and you are updating it in one table. Can you please let me know based on what condition you are trying to query. Also please tell the source table,field, Destination table, field so that I can get you a script.
Regards
Param
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2017 12:50 AM
Hi All,
var rec = new GlideRecord('u_test_plan');
- rec.addQuery('u_request_status','canceled');
- rec.addQuery('u_test_cancel_dateISEMPTY');
//rec.setLimit(3);
- rec.query();
- gs.print("row :: "+rec.getRowCount());
while(rec.next()) {
var dt = new GlideDateTime(rec.u_project_id.end_date);
gs.print('dt ' + dt.getDisplayValue());
rec.u_test_cancel_date = dt;
gs.print('Request id :: '+rec.u_request_id);
gs.print('Project_ID :: '+rec.u_test_cancel_date.getDisplayValue());
//rec.u_test_cancel_date.setValue(today);
gs.print('Project_ID :: '+rec.u_project_id.number);
gs.print('End Date :: '+rec.u_project_id.end_date.getDisplayValue());
rec.update();
}
It work for me..
Thank you for your help..
Regards,
Amol