service portal text is displaying with html tag

Swati44
Kilo Expert

I have a field on record producer called 'Please describe your issue below'(HTML type) mapped to 'short description'(multi line text).

Am writing business rule to convert the HTML to normal text:

(function executeRule(current, previous /*null when async*/) {


var a=current.short_description.getXHTMLValue();
//to remove HTML characters.
a= a.replace(/&(lt|gt);/g, function (strMatch, p1){
return (p1 == "lt")? "<" : ">";
});
var b = a.replace(/<\/?[^>]+(>|$)/g, "");
//to remove &amp;
var c=b.replace(/&amp;/g, '&');
current.setDisplayValue('short_description',c);


})(current, previous);

----------------------------------------------------------------------------

Now in short description field of incident am able to see only text.... But not in service portal....

 

find_real_file.png

2 REPLIES 2

Fabian Kunzke
Kilo Sage
Kilo Sage

Hello,

This won't fix you issue. But i would suggest actually putting the content into an html field. Or to change the field in the service portal to "string". That would simplyfy your development alot and i don't see any reason not to do either of these. Because writing a fully fletched html converter in Javascript can take alot.

 

Greetings

Fabian

Chandu Telu
Tera Guru
Tera Guru

HI Swathi,

 

check this link it may help you

https://community.servicenow.com/community?id=community_question&sys_id=e87f0725dbdcdbc01dcaf3231f9619ee