Generate link in client script gs.showFieldMsg

sherman_1206
Tera Contributor

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?
8 REPLIES 8

Akeel,   How are you embedding the link in 'Portal'.   Can you give the steps or syntax?


Can you tell me how to remove this fieldmsg in case the script is 'onchange' of a variable. Every time i choose another option or come back to the old option, the info msg appears again and again one after the other.



find_real_file.png


Hi Ramya,


Use hide field Message :


g_form.hideFieldMsg('variablename',true);


Like


g_form.hideFieldMsg('u_desktop', true);



Example


onChange:



var test=g_form.getValue('u_desktop');


if ( test == 'yes')


{


g_form.hideFieldMsg('u_desktop', true);


g_form.showFieldMsg('u_desktop','Please refer to the Reference Guide for Knowledge base Article Editors for instructions and tips to create End-User articles','info');


              return false;


}



It wont repeat again..


Adrian A_ Ghida
Kilo Contributor

I have face it the same situation, I just create a variable macro+widget with the text and the hyperlink, and then a UI policy that will condition that macro variable to be displayed only if in the field X = value Y.

Also some CSS to align that hyperlink.

 

Thanks,

Adrian