How to add a default attachment to an attachment variable in a catalog item.

sreeshsurendran
Tera Guru

How to add a default attachment to an attachment variable in a catalog item so that the user can download that attachment and add the updated attachment to that variable.

2 ACCEPTED SOLUTIONS

Karan Chhabra6
Mega Sage
Mega Sage

Hi @sreeshsurendran ,

 

You can achieve this using the following steps:

Step 1 : Attach the attachment to the catalog item, which you want to show up as default, example:

KaranChhabra6_0-1683285386490.png

 

Step 2 : Navigate to the 'sys_attachment' table, you'll notice that a new record has been created - copy the 'sys_id' of this record.

KaranChhabra6_1-1683285467126.png

 

Step 3: Create a onLoad catalog client script

KaranChhabra6_2-1683285554266.png

function onLoad() {
	
   g_form.setValue('attachment','b3db64fa97aea91082f2bb5ef053afb9'); // replace the sys_id with the one which you've copied in step 2
   
}

 

Result:

KaranChhabra6_3-1683285676491.png

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks,
Karan

 

 

 

 

 

View solution in original post

@Slava Savitsky  - thanks for the feedback, that's a good catch

@sreeshsurendran  - as a workaround for this, you can add your template in the description of the catalog item

KaranChhabra6_0-1683306378531.png

 

Click on the link icon and then select the link list as your attachment

KaranChhabra6_1-1683306436080.png

Change the title and text accodingly.

This method wont delete the attachment.

 

Thanks!

 

 

View solution in original post

7 REPLIES 7

Karan Chhabra6
Mega Sage
Mega Sage

Hi @sreeshsurendran ,

 

You can achieve this using the following steps:

Step 1 : Attach the attachment to the catalog item, which you want to show up as default, example:

KaranChhabra6_0-1683285386490.png

 

Step 2 : Navigate to the 'sys_attachment' table, you'll notice that a new record has been created - copy the 'sys_id' of this record.

KaranChhabra6_1-1683285467126.png

 

Step 3: Create a onLoad catalog client script

KaranChhabra6_2-1683285554266.png

function onLoad() {
	
   g_form.setValue('attachment','b3db64fa97aea91082f2bb5ef053afb9'); // replace the sys_id with the one which you've copied in step 2
   
}

 

Result:

KaranChhabra6_3-1683285676491.png

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks,
Karan

 

 

 

 

 

With this approach, when the user clicks the Delete button in order to upload their own version of the file, the attachment will not only be removed from the form, but also from the catalog item definition, which means the next user will not see any default attachment.

 

Before pre-populating the attachment variable, you need to create a copy of the file and use the sys_id of that copy in the client script.

Hi @Slava Savitsky , could you please show the working.

@Slava Savitsky  - thanks for the feedback, that's a good catch

@sreeshsurendran  - as a workaround for this, you can add your template in the description of the catalog item

KaranChhabra6_0-1683306378531.png

 

Click on the link icon and then select the link list as your attachment

KaranChhabra6_1-1683306436080.png

Change the title and text accodingly.

This method wont delete the attachment.

 

Thanks!