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 attachment from the record producer variable to target table as an attachment on the record

vishwa4hil
Tera Expert

Recently I was trying to copy attachment from record producer to a target table and from there copying into a data source for processing it.

 

This failed as the attachment was getting appended with zz_yy etc.

 

To resolve this I looked at multiple  community articles but the syntax given them was a little incorrect. 

I am posting this so that you don't have to search .

 

new global.VariableUtil().copyAttachment(producer.variable_name,'<target table name>', current.sys_id);
 
1. In the above code, remove variable name and add your variable name that you used for attachment.
2. add target table name where you want to copy the attachment to
3.current.sys_id is the record generated where the attachment will be copied to ( Note this is being used in context of record producer hence I have used current.sys_id)
 
1 ACCEPTED SOLUTION

vishwa4hil
Tera Expert

To resolve this I looked at multiple  community articles but the syntax given them was a little incorrect. 

I am posting this so that you don't have to search .

 

new global.VariableUtil().copyAttachment(producer.variable_name,'<target table name>', current.sys_id);
 
1. In the above code, remove variable name and add your variable name that you used for attachment.
2. add target table name where you want to copy the attachment to
3.current.sys_id is the record generated where the attachment will be copied to ( Note this is being used in context of record producer hence I have used current.sys_id)

View solution in original post

2 REPLIES 2

vishwa4hil
Tera Expert
new global.VariableUtil().copyAttachment(producer.attach_master_log.toString(),'x_htawa_dba_war_ha_claims_processor', current.sys_id);
 

vishwa4hil
Tera Expert

To resolve this I looked at multiple  community articles but the syntax given them was a little incorrect. 

I am posting this so that you don't have to search .

 

new global.VariableUtil().copyAttachment(producer.variable_name,'<target table name>', current.sys_id);
 
1. In the above code, remove variable name and add your variable name that you used for attachment.
2. add target table name where you want to copy the attachment to
3.current.sys_id is the record generated where the attachment will be copied to ( Note this is being used in context of record producer hence I have used current.sys_id)