The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Carlos,



Please go through the below link for more info.


http://www.servicenowguru.com/system-definition/advanced-templates/


Basically you can have onLoad client script where you can make the template to default.


Hi Pradeep,



Thanks for the useful answer , unfortunately I need a bit more of help to my level of knowledge. A Client script would be useful. I just started to do it but I do not know what to place in the onload function ?




Onload.JPG


Any extra help will be greatly appreciated



Carlos


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Carlos,



You have to use applyTemplate(template); //Pass template sys_id here


Please refer section 4 in the above link I have shared.


Shahed Shah1
Tera Guru

Hey Carlos



There's a couple of approaches here that you've hinted at, so I just wanted to clarify a couple of things.



With the general defaults they will apply when creating a new KB article and setting the value of the Knowledge base field. As an example (using an OOB demo):


  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)
  4. Now navigate to Knowledge -> Create New
  5. In the Knowledge field set the value to "Knowledge" (without the quotation marks)
  6. A message will popup like this:
    Screen Shot 2015-09-11 at 09.24.35.png
  7. Select OK and you will see that the text does get applied


Now, you can create Templates (per your first screen shot) which can be applied by a user. So let's create a template. While you're on the Knowledge form, right-click on the Form Header and select Template -> Edit Templates then click on New at the top of the list. For simplicity I created a Template like so:


  • Name=Knowledge
  • Table=Knowledge [kb_knowledge]
  • Short description=Test KB Template


And in the Template field, select Text from the drop down and give it a value like:


<h1>some html text</h1>


<p>is it working</p>



Test it by navigating to Knowledge -> Create New and selecting the newly created template by right-clicking on the Form Header and selecting it from the Template sub-menu.



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.


As you can see there is no need to go through much implementation to achieve this requirement. Though you can certainly look at the SNC Guru link for more complex templates, though I've not tried it .