Updating the source code using the HTML Source Editor on the TinyMCE Editor adds an extra tag (<p>&nbsp;</p>) after clicking Enter.


Steps to Reproduce

  1. Create a knowledge base article.
  2. Click the HTML icon to launch the HTML Source Editor. 
  3. Edit the source code to add the tag, <hr>.
  4. Click Update to save the article. 
  5. After the horizontal line in the article, click Enter.
    The pointer moves up to the first line in the article and an extra tag, <p>&nbsp;</p>, is inserted into the html source code right after the <body> tag.


Adding an extra paragraph tag when pressing the enter key is expected behaviour for third party products like TinyMCE, or even Microsoft Word, where if you want text directly on the next line you need to hold shift+enter.
ServiceNow will continue to implement TinyMCE's improvements as they become available. A workaround is described in the article below:

Alternatively you can use this onChange client script that will remove the trailing content: <p>&nbsp;</p>


function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {

	var fieldName = 'text';
	// use decodeURIComponent because   becomes " " when client script is written to the desktop form.
	var patterns = [decodeURIComponent('<p>%26nbsp;</p>'), '<p></p>'];
	var hasTrailingTag = false;
	for(var i=0; i < patterns.length; i++) {
		if (newValue.substr(-(patterns[i].length)) === patterns[i]) {
			hasTrailingTag = true;

	if (!hasTrailingTag)

	// Remove patterns from the end of the field value
	var lines = newValue.split('\n');
	for (i = lines.length-1; i >= 0; i--) {
		if (patterns.indexOf(lines[i]) > -1)
	newValue = lines.join('\n');

	// Set the clean value on the field
	g_form.setValue(fieldName, newValue);


Related Problem: PRB585174

Seen In

Berlin Patch 8 Hot Fix 1
Berlin Patch 9
Berlin Patch 9 Hot Fix 3
Calgary Patch 2 Hot Fix 5
Calgary Patch 3 Hot Fix 1
Dublin EA 1
Eureka Patch 10
Eureka Patch 11
Eureka Patch 3 Hot Fix 1
Eureka Patch 5
Eureka Patch 6
Eureka Patch 7
Eureka Patch 7 Hot Fix 1
Fuji Patch Hot Fix 1
Fuji Patch 10
Fuji Patch 12 Hot Fix 1
Fuji Patch 2 Hot Fix 1
Fuji Patch 3
Geneva Patch 7
Geneva Patch 8

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2019-05-21 11:38:50