Can we add a HTML link in showfieldmsg()

Rachael12
Tera Contributor

Hello, 

I want to a HTML link below a field and I was trying to do it through showfieldmsg() but unable to achieve.
I am able to achieve the requirement through macro+widget but there is a lot of distance between the message and field and client does not want that.

So, is it possible to achieve through  showfieldmsg?

Thanks in advance

8 REPLIES 8

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Using the regular g_form.showFieldMsg, etc: no not possible.

Like you mentioned, you would need to look for alternative ways, like for example DOM manipulation, macro, widget, etc..

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Allen Andreas
Administrator
Administrator

Hi,

As Mark stated, it's not possible with field message however, as you stated...it is possible with macro+widget and/or UI page. So you can create the UI page for back-end view, the macro+widget for portal view. Then create UI policy with the script tab to "desktop" and then in the true space, setDisplay to false for the portal macro+widget. This removes the gap in back-end view and on portal...it automatically doesn't show the UI page anyway.

 

(Edit: guess I'll edit my post to say...it's not possible with field message unless you do DOM manip, etc. which isn't best practice), but from the looks of the post below mine, it appears possible.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

The Machine
Kilo Sage

It takes a little work, but can be done...  Make sure isolate script is unchecked on the client script.  This adds a link out to Google as a field message on the incident form (impact field) onLoad.

function onLoad() {
    //Type appropriate comment here, and begin script below

    g_form.showFieldMsg('impact', 'This does not matter as it will change in the innerHTML snippet', 'info', false);

    var x = gel('incident.impact_fieldmsg');

    x.innerHTML = '<div class="fieldmsg-container" id="incident.impact_fieldmsg" aria-live="polite"><div class="fieldmsg notification notification-info">' + '<a href=' + '"https://google.com"' + 'target="_blank"' + '>' + 'This will link out to Google' + '</a>' + '</div>' + '</div>';

}

find_real_file.png

Hi,

I need to create the link in a EUP form. I tried this but was unable to create the link.