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.

Add Work notes Comment with Link to External Site

Dillin  Bradley
Tera Expert

Hello,

 

I am looking to update work notes with a dynamic link. With the link it will be dynamic based off of another field. We track Fedex shipping numbers in a specific field on the RITM and when it is populated it adds a work note to the INC that with that tracking number but I would like it to also be a link to FedEx with that tracking number. I have come up with the script below but it is not working as a HTML link and Im not sure whats missing or how to fix

 

var incGR = new GlideRecord("incident");

if(incGR.get(current.request.parent)){

incGR.work_notes = current.cat_item.name + " has shipped. Tracking #: " +current.getValue("u_tracking_send") +' ' 
+ [code]< href="https://www.fedex.com/fedextrack/?trknbr="+current.getValue("u_tracking_send")> [/code];

incGR.update();
}
1 ACCEPTED SOLUTION

Oh yup! I see it. You have a semicolon at the end of line 5, which terminates the statement. Instead of having a semicolon, you need to have a plus sign and move the following line up but in quotes. Like this:

 

incGR.work_notes = current.cat_item.name + " has shipped. Tracking #: " + current.getValue("u_tracking_send") + "[code]<a href='https://www.fedex.com/fedextrack/?trknbr=" + current.getValue("u_tracking_send") + "'>" + current.getValue("u_tracking_send") + "</a>[/code]";

View solution in original post

7 REPLIES 7

Oh yup! I see it. You have a semicolon at the end of line 5, which terminates the statement. Instead of having a semicolon, you need to have a plus sign and move the following line up but in quotes. Like this:

 

incGR.work_notes = current.cat_item.name + " has shipped. Tracking #: " + current.getValue("u_tracking_send") + "[code]<a href='https://www.fedex.com/fedextrack/?trknbr=" + current.getValue("u_tracking_send") + "'>" + current.getValue("u_tracking_send") + "</a>[/code]";

@Aylee Andersen THANK YOU VERY MUCH! You were very helpful, I did "Accept As Solution" but had one more question, do you know how I can make the link open in a new window? It currently tries to open in ServiceNow but obviously its not a ServiceNow link.

@Dillin Bradley 

 

Awesome! Glad I could help! All you have to do is add "target='_blank'" to your anchor tag and that should get you what you want. Here is a revised section of the line of code:

 

........<a href='https://www.fedex.com/fedextrack/?trknbr=" + current.getValue("u_tracking_send") + "' target='_blank'>" + .......