hyper link in showFieldMsg on load client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
How can I add hyper link using onLoad client script and
(for example the user will see 'click here' and it will redirect to google)
My field name is: u_priferia
table name: sn_slm_case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @Alon Grod
By default, ServiceNow's g_form.showFieldMsg treats text as plain string and escapes HTML tags.
OOB it is not supported.
You need to write an onLoad Client Script that pushes a placeholder message and dynamically updates the DOM element ( DOM is not recommended).
Refer for DOM onload script:
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello @Alon Grod ,
Here it look like :
You can try this code snippet :
function onLoad() {
var fieldName = 'u_incident';
var placeholder = "##placeholder##";
var url = "https://google.com"; /
g_form.showFieldMsg(fieldName, placeholder, 'info', false);
try {
var elements = document.getElementsByClassName("fieldmsg notification notification-info");
if(elements.length > 0) {
var str = elements[0].innerHTML;
str = str.substring(0, str.indexOf(placeholder));
elements[0].innerHTML = str + 'Please <a href="' + url + '" target="_blank">click here</a> for more information.';
}
} catch(e) {
// Fallback or error handling
}
}
Note : uncheck isolated script
If this helps you then mark it as helpful and accept as solution.
Regards,
Aditya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
g_form.showFieldMsg doesn't support HTML so your requirement is not possible
You can inform your customer about this platform limitation and instead show infoMessage on form
Note: There are approaches to achieve this with DOM manipulation but it's not recommended to use
💡 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 || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader