How to place a default html text in the knowledge text article field that shows automatically when you create a new article ?

carls
Kilo Explorer

G'Day ServiceNow gurus,

We just migrated to Fuji and we are starting to play with the knowledge base databases in our development instance.

We have   a knowledge template called "Systems new article" which basically fills the text underneath of the "Short description" with an HTML text. Now when I click "Create content" then I have to apply the template to get this default text as shown below

knowledge template.JPG

How can I make this template the default so I do not have to apply it ?


If I go to the general defaults then I can not place an HTML default in text

KB.JPG

I appreciate any advice.

Kind regards

Carlos

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Two points:


  • you can create a default template that is automatically applied when someone manually creates a new record on any table.   You do this by saving the template with the same name as the physical table name, in your case "kb_knowledge".   See Section 6 in this Wiki article - Creating a Template - ServiceNow Wiki.
  • for your default HTML text, you cannot enter rich text in the text field so you need to enter the actual HTML markup text

        ServiceNow.png


Doing that will result in your Text field looking like this when you create a new record:


        ServiceNow.png


View solution in original post

12 REPLIES 12

Hi Rashid,



Thanks for the comprehensive reply, In


Shahid Shah wrote:



  1. Navigate to Knowledge -> Knowledge Bases
  2. Select the Knowledge record
  3. In the Set default knowledge field values field select Text from the drop down and give it a value like "is it working?" (without the quotation marks)

I can not place an HTML default but even If I could then I can not place automatically as default



In the second part of your reply


Shahid Shah wrote:




You can get this to apply on load in a couple of ways:


  1. Create an onLoad Client Script with the code of applyTemplate('put the sys id in here');
  2. Create a new module under the Knowledge application (or another one) and in the Arguments add &sysparm_template= followed by the name of the template. Per this example the value would be &sysparm_template=MyKBTemplate.



I create this client script



Apply Template.JPG



but it is not working when I create a new template. Do you know why?



I also tried suggestion number 2 but I do not know "What Link Type" to use to combine with the arguments



I think that I am almost there just a bit of more extra help



Kind regards



Carlos


Hi Carlos,



The sys_id you are using is not proper. Remove 'sys_template_' from the begining.


Or simply go to Templates > Right click on your template record and click copy sys_id.



So it will look something like this -


applyTemplate('8c12b7130a0a0a6400c5ed6df604d768');



Thanks,


Tanaji


One more thing - This template will always get applied whenever you open the knowledge form irrespective of whether its a new record or an existing record.



If you want this to applicable only on new form then use below code -


function onLoad() {


    if(g_form.isNewRecord()){


              applyTemplate('8c12b7130a0a0a6400c5ed6df604d768');   //replace sys_id with yours


    }


}


Thanks Tanaji


You are welcome