Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Copy custom variable in record producer to OOTB record producer attachment

ronro2
Tera Contributor

Hey! 

In a record producer I have a custom variable of type attachment called 'bifoga_fil':

ronro2_0-1777024047068.png



So I want to copy this to the OOTB attachment on the record producer in the back-end, so that the attachment is visible in the banner above and in the logs. 

ronro2_0-1777023445003.png


I've marked what I mean with red. 

So, I am thinking an after insert business rule of some kind? What would that look like? 

I'm thankful for your help. 

All good, 

1 ACCEPTED SOLUTION

@ronro2 

the file should get attached to the record if you used the record producer script

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

29 REPLIES 29

@Ankur Bawiskar It did work! I had before put in the parent table, but when I put the specific child table that the record producer communicates to it worked! 🙂 Thank you so so much! 

Hi @ronro2 ,

  1. Open the sys_attachment table records.

  2. Check that the Table Name for the recently uploaded attachments is x_vgll_rail_task.

  3. Ensure it is not prefixed with ZZ_YY (e.g., it should not be ZZ_YYx_vgll_rail_task).

ronro2
Tera Contributor

@Rakesh_M this is what I see: 

ronro2_0-1777384482046.png

 

@Ankur Bawiskar I realised your solution is either or. So If I want it to show in the log, I must refer to the parent table. If I want it to show in the banner I must refer to the child table in for this script: 

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


In my case I need both.. so to show the attachment both in the log and in the banner of the record... So your solution is almost there but not quite there. 

@ronro2 

your record producer is on which table?

Your requirement as per question is to add that file from attachment variable to target record

That's working as per my script?

what other thing is required?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader