How to add hyperlink for g_form.showFieldMsg display message

poornima batchu
Tera Expert

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? 

17 REPLIES 17

Brad Bowman
Kilo Patron
Kilo Patron

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.";
}

BradBowman_0-1701797232785.png

 

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

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');
	}
}

BradBowman_0-1701878723695.png

 

This is giving a javabrowser console error