Attachment link/URL in worknotes .

Deepak92
Tera Contributor

Hi Team,

How can i achieve the below requirement.

When the agent attaches the attachment to ServiceNow, a link to the attachment should get added to work notes.

 Any help would be highly appreciated .

 

Thanks in Advance.

Regards

Deepak Bisht

1 ACCEPTED SOLUTION

Hi,

then use this but it won't be clickable link unless you give anchor tag

I have not used anchor tag in below code

var rec = new GlideRecord(current.table_name);
rec.get(current.table_sys_id);

var url = 'https://' + gs.getProperty('instance_name') + '.service-now.com/sys_attachment.do?sys_id=' + rec.sys_id;

rec.work_notes = url;

rec.update():

Regards
Ankur

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

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can write after insert BR on sys_attachment table

Note: this change will be seen once user refreshes the form

Condition: current.table_name == 'incident'

Script:

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

    // Add your code here

var rec = new GlideRecord(current.table_name);
rec.get(current.table_sys_id);

var url = '<a href="' + gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + current.getTableName() + '.do?sys_id=' + current.sys_id + '">' + rec.getDisplayValue() + '</a>';

rec.work_notes = '[code]' + url + '[/code]';

rec.update():

})(current, previous);

Regards
Ankur

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

@Deepak 

Thanks for marking my response as helpful.

Regards
Ankur

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

Hi Ankur,

Thanks for the reply .

I am very close to it.i got the work notes updated with  incident no (Which is Hyperlink) so whenever i am clicking on it , it directing  me to homepage screen page and then giving me options for attachment.

Below are my ask

1. I need Explicitly URL so that i can transfer it to someone ( so that if someone want they access the attachment by just clicking )??

2. I don't want to redirect it to Homepage , i want it to be on same page??

is this achievable?

Waiting for your comment

Regards
Deepak

 

 

Hi,

whenever you show attachment link and user clicks that and they are logged into the instance the file will get auto downloaded

for explicit attachment link do this

var url = '<a href="' + '/' + current.getTableName() + '.do?sys_id=' + current.sys_id + '">' + rec.getDisplayValue() + '</a>';

Regards
Ankur

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