How to copy the attachment from table record to record producer using UI action

naveen80
Tera Contributor

Hi Experts,

 

I was trying to attach the files of incident record to record producer on click of UI button.

 

I've tried 'GlideAttachment.copy()' which helps only from record to record, but not record to form.

 

Can you please advise, how to make this work.

 

Thanks in advance..!!

 

Regards,

Naveen.

1 ACCEPTED SOLUTION

@naveen80 

do this

1) create a string variable on record producer and give it higher order

2) pass the incident record sysId from URL parameter when you redirect user to record producer

3) use onLoad catalog client script and get that URL parameter value and set it in variable and hide it

4) then use Record producer script to copy attachment

GlideSysAttachment.copy('incident', producer.variableName, 'target_table', current.sys_id);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

17 REPLIES 17

Hi @Ankur Bawiskar ,

what's the motive of showing the files on record producer? - Files will be the reference to technical teams to work on the demand request.

 

Did you try g_form.getUniqueValue() for portal? - YES, It returns me the Sys_id value of Record Producer item.

 

Note: I've to build the same requirement in custom table (which holds the templates of shipping invoice). Where end-users filter the data in custom table with their requirements and incase, if users find the partial match template record, end-users will click on the demand request button to modify the selected template .

 

Regards,

Naveen.

 

 

@naveen80 

so what's the error when you are using the script?

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

Hi @Ankur Bawiskar ,

 

There is no error, sys_id of Record Producer item('sc_cat_item_producer') is of no use, bcoz it doesn't show the attachments on the portal form.

 

We should be able to attach the attachments on the target table record of the Record Producer.

 

Let us assume, I've manually attached an attachment on the RP given below.

naveen80_0-1696846930764.png

This attachment is stored in the target table below with random generated sys_id before the form is submitted.

 

naveen80_1-1696846999889.png

 

I was trying to fetch that sys_id before loading the form.

 

Hope you understood the issue.

 

Regards,

Naveen.

@naveen80 

that is not possible.

if your actual use-case is to transfer file from incident record to the target record generated from record producer then there is another way for this

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

Hi @Ankur Bawiskar ,

 

What is the other way you recommend for this requirement?

 

Could you help me with the details.

 

Regards,

Naveen.