Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Copying Images from Parent to Child table in Servicenow

i_sachin_
Tera Contributor

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);

0 REPLIES 0