hyper link in showFieldMsg on load client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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 weeks ago - last edited 3 weeks ago
Hey @Alon Grod
You can achieve this using DOM manipulation from an onLoad Client Script.
function onLoad() {
g_form.showFieldMsg('u_priferia', 'Click here', 'info');
setTimeout(function() {
var msgs = document.querySelectorAll('.fieldmsg');
msgs.forEach(function(msg) {
if (msg.innerText.indexOf('Click here') > -1) {
msg.innerHTML = '<a href="https://www.google.com" target="_blank">Click here</a>';
}
});
}, 1000);
}
Important: Make sure Isolate Script is unchecked on the Client Script, otherwise DOM APIs such as document.querySelectorAll() will not be accessible.
Note: Direct DOM manipulation is generally not recommended in ServiceNow because DOM elements and CSS classes can change across releases, which may cause scripts to break after upgrades. Where possible, consider supported alternatives such as UI Macros, Formatters, HTML fields, or Workspace components depending on your use case.
***********************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hey @Alon Grod
Hope you are doing well.
Did my previous reply answer your question?
If it was helpful, please mark it as correct ✓ and close the thread . This will help other readers find the solution more easily.
Thankyou & Regards
Vaishali Singh
Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb