Copying Images from Parent to Child table in Servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 10:15 AM
I have a scenario, where technicians upload images for end users within Work Order Tasks using a custom field of type "Additional Comments (Customer Visible) Translated HTML". These images are essential for communication and documentation purposes. Now, I need to find a way to copy these images from the Work Order Task to the parent Work Order itself.
I have attempted to achieve this using the following script:
when to run: async, update
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('wm_order');
gr.addQuery('number', current.u_parent_wo); // Assuming u_parent_wo is the field on wm_task that stores the parent work order's number
gr.query();
if (gr.next()) {
GlideSysAttachment.copy("wm_task", current.sys_id, "wm_order", gr.sys_id); // Assuming current.sys_id refers to the work order task's sys_id
gr.update();
}
})(current, previous);