HTML support for work note

jobin1
Tera Expert

Hi All,
Is there any way that we can push HTML format in work note section from server side code ?

3 REPLIES 3

KrishnaMohan
Giga Sage

@jobin1  do you mean, save the text with html tags as shown below? then it is straight forward 

KrishnaMohan_0-1759134607243.png

var incident = new GlideRecord("incident");
//example
if(incident.get("558c70694737e2508aca35ca116d436e")){ 
incident.work_notes = "<p>This line will be preserved.\nAnd this is the next line.<p>";
incident.update()
}

 

 

Or do you want render html  in worknotes like below?

 

var incident = new GlideRecord("incident");
if(incident.get("558c70694737e2508aca35ca116d436e")){

var myHtmlContent = "The **Work Note** has been updated with formatted text.<br/>";
myHtmlContent += "<ul><li><span style='color: blue;'>Important Detail 1</span></li>";
myHtmlContent += "<li><span style='font-weight: bold;'>Detail 2</span></li></ul>";
myHtmlContent += "Click <a href='https://yourinstance.service-now.com/nav_to.do?uri=incident.do?sys_id=" + incident.sys_id + "'>here</a> to view the record.";

// Set the work_notes field
incident.work_notes = "[code]"+myHtmlContent+"[/code]";

incident.update()
}

 

If this helped to answer your query, please mark it helpful & accept the solution.
Thanks!
Krishnamohan

Ankur Bawiskar
Tera Patron
Tera Patron

@jobin1 

yes that's possible.

wrap the HTML code inside [code][/code] tag and you are done

something like this in background script on incident to update as example

How do I display a clickable URL in my work notes? Please do not use the example that uses [code]. 

This KB explains

Render journal field entries as HTML 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Bhuvan
Mega Patron

@jobin1 

 

Yes, it is supported. Refer below thread for usage and system properties to configure

 

https://www.servicenow.com/community/developer-forum/additional-comment-hyperlink-not-in-test-instan...

 

https://www.servicenow.com/docs/bundle/zurich-platform-administration/page/administer/field-administ...

 

As per community guidelines, you can accept more than one answer as accepted solution. If my response helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan