Adding hyperlinks in javascript

turnea
Mega Expert

I have a workflow in which I need to add the Catalog Task's item description in script and include three hyperlinks within the text.   I tried doing it with HTML within the javascript but it didn't seem to like the quotation marks / apostrophes and it just didn't put anything into the description.   Pretty sure it's because the script got buggy from all of the quotation marks.   Just wondering if anyone had a better idea to get the hyperlinks into a workflow task?

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could pretty easily add a link to a journal field like work notes through the script area on the task activity with something like this:



var url = 'www.google.com';


var linkName = 'Link Name';


task.work_notes = '[code]<a href="' + url + '">' + linkName + '</a>[/code]';



The key to adding a link in a journal field is the code tags.


View solution in original post

5 REPLIES 5

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could pretty easily add a link to a journal field like work notes through the script area on the task activity with something like this:



var url = 'www.google.com';


var linkName = 'Link Name';


task.work_notes = '[code]<a href="' + url + '">' + linkName + '</a>[/code]';



The key to adding a link in a journal field is the code tags.


Hi Brad,



This did end up working properly for me.   I was struggling for a bit but I realized that I missed a very small part of code which completely stopped the script.   Thank you so much for your insight!



Amandah


Loudigi
Kilo Sage

Here's a sample to try in your script:



template.print('Please visit this <a href=http://webpage.com>Link</a> \n');





turnea
Mega Expert

Thank you!   I'll give this one a try.