
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 02:42 AM
Morning guys.
Just a quick one for today: can I change the parent of a Work Order Task to attach the WOT to another WO? I guess not, but some of you smart people might have an idea. 🙂
Daniel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 06:35 AM
Hi Daniel,
OOB we can't do it. but if you are willing to use a background script please use the below script to achieve it
var taskNumbers = "WOT0008001";// number of the work order task record. if you want to update it give comma separet values like "WOT0008001,WOT0008002"
var newParentNumber="WO0008003"// number of the work order we are gonna use as a new parent
var woGr=new GlideRecord('wm_order');
woGr.addQuery('number',newParentNumber);
woGr.query()
if(woGr.next()){
var wot=new GlideRecord('wm_task');
wot.addQuery('number','IN',taskNumbers);
wot.query();
while(wot.next()){
wot.setWorkflow(false)
gs.info("update the parent of workorder task : "+wot.number+" -- new parent : "+ newParentNumber+" ---- old parent : "+wot.parent.number );
wot.parent= woGr.sys_id;
wot.update()
}
}
Please mark it as helpful/correct If my answer is helpful in any way,
Best regards,
Thameem

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 06:35 AM
Hi Daniel,
OOB we can't do it. but if you are willing to use a background script please use the below script to achieve it
var taskNumbers = "WOT0008001";// number of the work order task record. if you want to update it give comma separet values like "WOT0008001,WOT0008002"
var newParentNumber="WO0008003"// number of the work order we are gonna use as a new parent
var woGr=new GlideRecord('wm_order');
woGr.addQuery('number',newParentNumber);
woGr.query()
if(woGr.next()){
var wot=new GlideRecord('wm_task');
wot.addQuery('number','IN',taskNumbers);
wot.query();
while(wot.next()){
wot.setWorkflow(false)
gs.info("update the parent of workorder task : "+wot.number+" -- new parent : "+ newParentNumber+" ---- old parent : "+wot.parent.number );
wot.parent= woGr.sys_id;
wot.update()
}
}
Please mark it as helpful/correct If my answer is helpful in any way,
Best regards,
Thameem

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 06:55 AM
Hi Thameem
Wow, that is really awesome! Thank you very much for this cool solution! That helped me a lot!
Daniel