- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 06:44 AM
Hi Team,
We have a child table "sn_ind_tmt_orm_order_line_item" with column as 'u_solution' ,its a string field and a parent table 'sn_csm_om_order_line_item' with column as 'temp_solution', its also a string field.
Now the requirement is to Delete the field on child table and before deleting it we need to copy the data from child column to parent column. Can you tell what script to write or how to achieve this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 06:53 AM - edited ‎10-30-2023 06:55 AM
Try this script.
var childLineItem = new GlideRecord('sn_ind_tmt_orm_order_line_item');
childLineItem.addEncodedQuery('u_solutionISNOTEMPTY');
childLineItem.query();
while(childLineItem.next()){
var parentLineItem = new GlideRecord('sn_csm_om_order_line_item');
if(parentLineItem.get(childLineItem.getValue('sys_id'))){
parentLineItem.setValue('temp_solution',childLineItem.getValue('u_solution'));
}
}
Caution: Please run this script initially for one record by setting the limit 1 childLineItem.setLimit(1); if the change looks good then run for all records. Also, run this script on sandbox first if changes are good then move to other instances.
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 06:53 AM - edited ‎10-30-2023 06:55 AM
Try this script.
var childLineItem = new GlideRecord('sn_ind_tmt_orm_order_line_item');
childLineItem.addEncodedQuery('u_solutionISNOTEMPTY');
childLineItem.query();
while(childLineItem.next()){
var parentLineItem = new GlideRecord('sn_csm_om_order_line_item');
if(parentLineItem.get(childLineItem.getValue('sys_id'))){
parentLineItem.setValue('temp_solution',childLineItem.getValue('u_solution'));
}
}
Caution: Please run this script initially for one record by setting the limit 1 childLineItem.setLimit(1); if the change looks good then run for all records. Also, run this script on sandbox first if changes are good then move to other instances.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2023 01:48 AM
@Sandeep Rajput I was able to write the simple script to achieve this but yours is also correct,