Field Messages - showFieldMsg()

revlass
Tera Contributor

I need help embedding a link into a field message.
I have tried the following...

var str = "here";
if (g_form.getValue('service_type') == 'System Request') {
g_form.showFieldMsg('service_type', 'You are submitting a system request; please provide the following additional information regarding your request: \nCost/Benefit Analysis (Please complete the spreadsheet found ' + str.link('www.something_here.com') + ' and attach to this request using the paperclip icon)', 'info', false);
}

The result was...

You are submitting a system request; please provide the following additional information regarding your request: Cost/Benefit Analysis (Please complete the spreadsheet found a href="www.something_here.com">here a and attach to this request using the paperclip icon)

Any help on this would be great. Thanks!

17 REPLIES 17

revlass
Tera Contributor

Thanks, Dale! Your solution worked great!


Hi Revlass, 

Can you please guide me on how it worked? 

Thanks

Brad Bowman
Kilo Patron
Kilo Patron

I realize this is an old post, but for anyone else who stumbles upon it, I was able to get Dale's solution working in Vancouver in the native UI.  This example on the Caller field of the Incident form:

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-1701797041327.png