Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Copy URL

chanikya
Kilo Sage

hi,

i wanna copy URL of attachments into Incident Table field u_url.

find_real_file.png

My scripts not working....

BR Script: Table: incident   before --insert/update 

var producer_id = gel('sysparm_item_guid').value;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name', 'incident');
gr.addQuery('table_sys_id', producer_id);
gr.query();

if(gr.next())
{
current.u_url=gr.location.href;
}

 

Or-------------------------

BR Script: Table: sys_attachment   before --insert/update 

var grr=new GlideRecord('incident');
grr.addQuery('sys_id',current.table_sys_id);
grr.query();
if(grr.next)
{
var hrf=location.href;
grr.u_url=hrf;
grr.update();
}

 

 

 

 

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Or if its just a list of all sys_attachments you are after:

current.u_url_field_or_something = gs.getProperty('glide.servlet.uri') + 'sys_attachment_list.do?sysparm_query=table_sys_id=' + current.getUniqueValue();

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

9 REPLIES 9

there are one UI-Page is there.

by using UI-Page -one button Presented in Incident table..so Can i use this script from UI - Page?

it is working Great ..!!!..

Thanks a lot MARK...!!!

No worries, glad to help.

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

No worries, glad to help.

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

No worries, glad to help.

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn