Generate link in client script gs.showFieldMsg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2011 05:44 AM
We can use a gs.showFieldMsg to display text near a field. What if we want to make part of that text a link?
function onChange(control, oldValue, newValue, isLoading, isTemplate) { //If the page isn't loading if (!isLoading) { //If the new value isn't blank if(newValue != '') { //Type appropriate comment here, and begin script below var bs = new GlideRecord("cmdb_ci_service"); if(bs.get( newValue ) ){ var dept = new GlideRecord('cmn_department'); if( dept.get( bs.u_service_provider ) ){ var info = 'Service Provider: <a href="nav_to.do?uri=cmn_department.do?sys_id="'+dept.sys_id+'>'+dept.name+'</a>\n Service Category: '+bs.u_service_category; g_form.showFieldMsg('u_business_service', info, 'info'); } } } } }
Problem is this field message shows the
"<a href="portion as well instead of displaying it as HTML. Is there a way to can generate a link to a record in a showFieldMessage?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2011 05:53 AM
Bump.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2011 07:17 AM
Looks like field messages don't support HTML. You could request that as an enhancement. I think it should be built-in. As a workaround, you could add a message at the top of the form that does accept HTML like this...
g_form.addInfoMessage(info);
If you're not afraid of managing a custom script you can mimic the behavior of a field message with your own client script like this...
//Insert a link to 'google.com' in an info message under the 'caller_id' field on the 'incident' form
$('element.incident.caller_id').insert({
after: '<tr class="info_message_row"><td colspan="2"><div class="outputmsg_info"><img src="images/outputmsg_success.gifx" alt="Informational Message"><a href="http://www.google.com">Google</a></div></td></tr>'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2011 09:40 AM
I am alright with implementing that script my concern is regarding the slippery slope customizations like these can put you down in terms of bugs during upgrades. But thanks for the information I will check into this and potentially submit an enhancement request.
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2012 10:41 AM
Inside my UI Policy I am running the following script.
function onCondition() {
g_form.showFieldMsg('length_of_hire','some text','info');
$$('div.outputmsg_info')[0].innerHTML="You cannot raise new starters through this wizard. Please visit Portal";
}