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

Aylee Andersen
Kilo Sage

Hello @Dillin Bradley,

 

Looking at your code snippet, you have your HTML link defined incorrectly. It's supposed to be an anchor (<a>) tag. Here is some documentation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a.

 

Basically, your link should look like the following:

<a href="https://www.fedex.com/fedextrack/?trknbr="+current.getValue("u_tracking_send")>[whatever you want the link to say]</a>

 

Also, you need to have all of the text as a string, even though it's HTML. Something like this should work:

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

Hope that helps point you in the right direction!

@Aylee Andersen thanks for the quick reply, I tried that and am getting the following error? Any ideas? Im not the best at coding and am unsure how to fix!

 

DillinBradley_0-1695300770371.png

 

@Dillin Bradley 

 

Based on the error, it looks like your quotation marks are out of sync somewhere. However, I think they got messed up before the section that I can see in the screenshot. Would you mind sharing a screenshot of the whole line? That should let me see where the error is.

@Aylee Andersen 

Here is the entire line! Sorry about that, I didnt realize I didnt get it all!

DillinBradley_0-1695314945924.png