Attachment Link in Service Portal

Arun87
Giga Contributor

Hi,

We have created catalog item and we have used attachment variable to attach the attachment while creating request in ServiceNow. Once the request is submitted approver is using service portal to approve the request but he is not able to see the attachment which is attached while creating the request. Could anyone help me how to download the attachment from the variable in Service Portal.

1 ACCEPTED SOLUTION

Hi,

Glad to know that my approach worked to show the attachment in portal view.

You can only upload 1 file in attachment variable then how can multiple files be attached?

Your question was around copying the file from attachment variable to approval record for which the solution I shared has worked.

Please mark my response as correct & close the thread so that it benefits future readers.

Regards
Ankur

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

View solution in original post

15 REPLIES 15

Bhaba
Tera Expert

Hi Arun,

Create a button and add the link to attachment record into the button for the respective record. Users will then be able to click on the button and download the attachment file.

<a href="sys_attachment.do?sys_id=">
    <button class="btn btn-primary btn-sm pull-right">Download</button>
</a>

Hope this helps you. Let me know for any query.

Thanks

Arun87
Giga Contributor

Hi,

Could you please help where we have create button.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

that attachment is present on variable of RITM and unless you copy that to Approval record it won't show

Here is the business rule to copy that attachment from RITM variable to Approval record

Then it would show

After Insert: sysapproval_approver

Condition:

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("sys_attachment");
	gr.addQuery("table_name", "ZZ_YY" + current.source_table);
	gr.addQuery("table_sys_id", current.sysapproval);
	gr.query();
	if (gr.next()) {
		gr.table_name = current.getTableName();
		gr.update();
		new global.VariableUtil().copy(gr.sys_id, current.getTableName(), current.sys_id); 
	}

})(current, previous);

Regards
Ankur

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

Hi Ankur,

  I have tried it but it is not working. Below is the script i have used it,

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var gr = new GlideRecord("sys_attachment");
    gr.addQuery("sc_req_item", "ZZ_YY" + current.source_table);
    gr.addQuery("table_sys_id", current.sysapproval);
    gr.query();
    if (gr.next()) {
        gr.table_name = current.getTableName();
        gr.update();
        new global.VariableUtil().copy(gr.sys_id, current.getTableName(), current.sys_id); 
    }

})(current, previous);