How to add clickable URLs in comments

Spandana P
Tera Contributor

Hello ,

We have this comments field which is of Journal input type on form, with this field we communicate with end users, Currently this field is not useful to send clickable links, just the text could be sent but sometimes we would need to send the end users Links/URLs which are clickable.

 How to achieve this with out the need to create a new field for URLs as we are not supposed to create any new fields due to license issues?

 

 

 

Thanks,

Spandana.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you need to wrap the html tag within [code][/code]

Example

current.comments = [code]<a href="https://google.com" target="_blank">Google</a>[/code];

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Yes, if you want clickable you will need to use [code][/code] and enclose with html tags with link

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

@Spandana P 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

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

Patiha
Kilo Contributor

Hi @Spandana P ,

Were you able to achieve this? I have the same requirement. Could you pls let me know if it solved your query.

Thanks!!

Hi @Patiha 

I was able to achieve it using another field. I was not allowed to create a new field so I used existing field "user input"- this is a string field. what we do now is that if we want to add clickable links to comments, we first add the link in the "user input" field and save the form. I wrote a script that adds https tags to links in user input and then add it to comments . with this we were able to add clickable urls in the comments. If we want to add more than one links, we just add the links in the user input field separated by comma. 

-->Before Business rule (insert/update):

(function executeRule(current, previous /*null when async*/ ) {
	var links = current.user_input;
	var arr = links.split(',');
	var finalArr = [];
	for (var i = 0; i < arr.length; i++) {
		if ((arr[i]).indexOf('http://') == -1 && (arr[i]).indexOf('https://') == -1) {
			arr[i] = 'https://' + arr[i];
		}
			var notes = '[code]<a href="' + arr[i] + '" target="_blank">' + arr[i] + '</a>[/code]' + ' added';
			finalArr.push(notes.toString());
		//}
	}
	current.comments.setJournalEntry(finalArr.join('\n'));
	current.user_input = ' ';
})(current, previous);

make sure that the field you use for this (ex: user_input) is not being used for any other purposes.