- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi Team,
I have requirement where I have to populate clickable Link in string field on alm_asset table using background script.
Field: u_instruction (String field)
This code is not working; the link is non clickable.
var linkURL = 'https://example.com';
var link = '<a href="' + linkURL + '" target="_blank">' + linkURL + '</a>';
var message =
'This customer has unique requirements – Refer to Read Me First document located in Library before servicing device(s). ' +
'Live link:' + link;
var gr = new GlideRecord("alm_asset");
gr.addEncodedQuery(encodedQuery);
gr.query();
while (gr.next()) {
gr.u_instructions = "";
gr.update();
}
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
you can't add link in a string field. that's OOTB limitation.
It clearly says it's string field and won't support HTML tags/links.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago - last edited 6 hours ago
Hi @Abhijit Das7,
to have a clickable link, you need to add it between the [code] tags
[code]<a href="https://www.yourlink.com">Link Name</a>[/code]
Also, if you plan to do it via background script, perhaps create a fix script (it is pretty much the same thing, giving you option to save that code).
EDIT: your code will clear the u_instruction field, is that on purpose?
var gr = new GlideRecord("alm_asset");
gr.addEncodedQuery(encodedQuery);
gr.query();
while (gr.next()) {
gr.u_instructions = "";
gr.update();
}
EDIT 2:
As Ankur stated in another reply, this is not possible for a string field. What I shared is applicable for journal fields only - Work Notes or Additional Comment, not any other field...
100 % GlideFather experience and 0 % generative AI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
you can't add link in a string field. that's OOTB limitation.
It clearly says it's string field and won't support HTML tags/links.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hi @Abhijit Das7 ,
As Other expert said String is not allowed for showing clickable link. Standard string fields will display HTML code as plain text only.
Create a field u_link Field with type html. In client script, when creating the link, create links with <a href="url"></a>, try something like this:
for (i=0; i<arr.length; i++) {
var url = "<a href="https://www.servicenow.com" + arr[i] + "></a> ";
g_form.setValue('u_link", url);
}
