Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to change to font style of HTMl field

dvelloriy
Kilo Sage

Hi Community

 

I have an HTML field "Introduction" on knowledge form. I have set the default font style as Tahoma and font size 12 pt.

This is done by updating the dictionary default value:

<p><span style="font-family: tahoma; font-size: 12pt;">&nbsp;</span></p>

 

This is working fine on most knowledge templates but there is 1 template where we are setting some prepopulated text in this field via on load client script due to which the default style changes to Verdana and font size to 8 pt.

 

Below is the client script:

function onLoad() {
//Type appropriate comment here, and begin script below
var base = g_form.getValue('kb_knowledge_base');
var versionValue = g_form.getValue('version');

if(base == '42a1f18647dc9d50da21ebbd436d432e' && versionValue=='')
{
g_form.setValue('short_description', 'How to');
g_form.setValue('u_kb_introduction', 'This article');

}

 

is there a way to fix this font problem? i tried several ways however it does not seem to work:

 

//var element = g_form.getControl('u_kb_introduction').getElement();
var element = document.getElementById('u_kb_introduction');
// Set the font style
element.style.fontFamily = 'Tahoma';
element.style.fontSize = '12px';

 

1 ACCEPTED SOLUTION

-O-
Kilo Patron

You need to add the HTML that sets styles to the field's value, not to the control that hosts the HTML.

g_form.setValue('u_kb_introduction', '<p><span style="font-family: tahoma; font-size: 12pt;">This article</span></p>')

View solution in original post

8 REPLIES 8

What if you eliminate the span element and add the style attribute to the p element?

gnewuser
Tera Contributor

That helped. Thanks so much for your time

You're most welcome 🙂

gnewuser
Tera Contributor

 I also have it on the defualt value of the field in the table.