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-05-2023 08:15 AM - edited 12-05-2023 09:29 AM
You didn't specify if you need to do this on a Catalog Item variable or a table record field. Here's an example using the Caller field on the Incident form in the native UI with Isolate Script unchecked since we are using the verboten DOM manipulation:
function onLoad() {
// Show an info message with an embedded hypertext link.
var str = "";
var placeholder = "##placeholder##";
g_form.showFieldMsg('caller_id', placeholder, 'info', false);
str = this.document.getElementsByClassName("fieldmsg notification notification-info")[0].innerHTML;
str = str.substring (0, str.indexOf(placeholder));
this.document.getElementsByClassName('fieldmsg notification notification-info')[0].innerHTML = str + "Please <a href='http://www.ibm.com' target='_blank'>Click here</a> for more information.";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 02:23 AM
hello,
Thanks for your reply but this needs to be implemented for variable and there is a certain condition applied on this variable..Say the varibale name is country --for India value only the display message should pop up. Display message should contian..Please submit your request through xyz.com (I need to provide the hyperlink for xyz.com).
Please provide the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 04:02 AM - edited 12-06-2023 08:07 AM
My solution also works on Catalog Item variables. Use the variable name in place of the field name. To make it conditional onLoad or onChange, or both, just wrap this in an if statement that evaluates the value of the variable. If doing this onChange, have an else block that uses g_form.hideFieldMsg. This example uses a Select Box type variable:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'in') {
// Show an info message with an embedded hypertext link.
var str = "";
var placeholder = "##placeholder##";
g_form.showFieldMsg('v_select', placeholder, 'info', false);
str = this.document.getElementsByClassName("fieldmsg notification notification-info")[0].innerHTML;
str = str.substring (0, str.indexOf(placeholder));
this.document.getElementsByClassName('fieldmsg notification notification-info')[0].innerHTML = str + "Please <a href='http://www.ibm.com' target = '_blank'>Click here</a> for more information.";
} else {
g_form.hideFieldMsg('v_select');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 07:34 AM
This is giving a javabrowser console error