How to add hyperlink for g_form.showFieldMsg display message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 07:57 AM
Hi all,
I'm trying to add a hyperlink for g_form.showFieldMsg which redirects to a portal. I have seen in the community it is not possible for showfiledMsg. client is expecting only display message they are not okay to add it as an info message
Could anyone suggest the best alternative ways to achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 07:39 AM
in the above image it's working in native.
Are you checking in portal? Possibly it won't work there due to DOM manipulation.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 11:43 AM
Needing to use this in Service Portal would have been excellent information to have at the outset - along with needing it conditionally, and on a Catalog Item variable as opposed to a table field,.........
One alternative that works in both interfaces is to create a variable with the type Rich Text Label (which should sound like a familiar suggestion), then use a simple, administration beginner's-level Catalog UI Policy to hide it unless another variable's value is whatever your requirement is
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 12:40 AM
Thank you so much I have used rich text variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2024 11:18 AM
Great solution! I applied that for the same purpose in my personal DEV instance. I struggled for a bit since I was using the inner HTML code within an AJAX function. I just removed the "this" keyword and it worked perfectly.
Much appreciated!
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
newValue = g_form.getValue('kb_article'); //Value from field on a form
var base_uri = new GlideAjax('kbUri'); //script include to get base instance URL ('glide.servlet.uri' ) in the client script
base_uri.addParam('sysparm_name', 'kburl');
base_uri.getXML(GetUri);
function GetUri(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var uri = answer + "kb_view.do?sysparm_article=" + newValue;
var urlUri = '<div><a class="web" target="_blank" href="' + uri + '">' + newValue + '</a></div>';
var msg = ('Click on the link below to see the KB article in a new tab.' + urlUri);
var str;
var placeholder = "##placeholder##";
g_form.showFieldMsg('sub_category', placeholder, 'info', false);
str = document.getElementsByClassName("fieldmsg notification notification-info")[0].innerHTML;
str = str.substring(0, str.indexOf(placeholder));
document.getElementsByClassName('fieldmsg notification notification-info')[0].innerHTML = str + msg;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 08:17 AM
Hi @poornima batchu,
Yes. This is limitations for g_form.showFieldMsg.
You can use the Rich Text Label variable type and include the URL.
Types of service catalog variables
If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers! 👍🏻
Thanks,
Sagar Pagar