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.

Ankur Bawiskar
Tera Patron
Tera Patron

Often, there's a need to copy attachments from a record producer's attachment variable to the target record. Unfortunately, there's no direct out-of-the-box solution for this in ServiceNow.

However, you can achieve this by using the record producer script. Here's how you can do it:

// pass the attachment variable name
// pass the target table name associated with the record producer

new global.VariableUtil().copyAttachment(producer.<variableName>,'<tableName>', current.sys_id);

// repeat this line again for another variable if required

Output Comparison: Native and Portal

When running the script, here's the output you can expect in both the native and the portal:

copy attachment variable to target record.gif

Comments
Scotty Williams
Tera Contributor

Howdy!

Do you know if there's a way to do this with attachments within a MRVS?

 

I tried the script logic below but no dice - any other magic you know of to make this possible?

 

Thanks!

Scotty

 

new global.VariableUtil().copyAttachment(producer.[mrvs_internal_name].[mrvs_variable_name], 'sn_customerservice_case', current.sys_id);
Version history
Last update:
‎01-23-2025 04:22 AM
Updated by:
Contributors