How to remove HTML tags from Rich description and description in the list view

Suvetha S
Tera Contributor

Hi All,

 

How to remove HTML tags from Rich description and description field in the list view of HR agent workspace? We are populating the rich description with a custom  business rule and there is a oob business rule that copies from rich description to description. 

SuvethaS_0-1670569528833.png

 

Below is the BR for populating rich description. Its working fine in the native view and workspace view. but those tags came up in the list view. 

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

/* Created as part of requirement: STRY0011083, where the Record Producer fields needs to be copied to HR Task Description */
var totalDescription = '';
var grQuestion = new GlideRecord("question_answer");
grQuestion.addEncodedQuery("table_sys_id=" + current.sys_id);
grQuestion.orderBy('order');
grQuestion.query();
while (grQuestion.next()) {
if (grQuestion.question.type == '8' && grQuestion.question.reference != '') {
totalDescription += '<b>' + grQuestion.question.getDisplayValue() + ' : ' + '</b>' + getValue(grQuestion.value, grQuestion.question.reference) + '<br><br>';
}
else if (grQuestion.question.getDisplayValue() == '') {
totalDescription += "<b>----------------------------------------------------------------------------------------------</b><br><br>";
}
else {
totalDescription += '<b>' + grQuestion.question.getDisplayValue() + ' : ' + '</b>' + grQuestion.value + '<br><br>';
}
}
function getValue(id, table) {
var grDetails = new GlideRecord(table);
if (grDetails.get(id)) {
return grDetails.getDisplayValue();
} else { return ' '; }
}
var hrTask = new GlideRecord('sn_hr_core_task');
hrTask.get(current.sys_id);
hrTask.rich_description = 'The following details have been provided:' + '<br><br>' + totalDescription;
hrTask.update();

})(current, previous);

 

4 REPLIES 4

RaghavSh
Kilo Patron

Check if the below property is there in sys_properties "glide.ui.escape_html_list_field".

 

Name : glide.ui.escape_html_list_field

Type : True/False

Value : False

 

If property does not exist create with above values and check.


Please mark the answer correct/helpful accordingly.

 


Raghav
MVP 2023

newhand
Mega Sage

HI @Suvetha S 

Try this  

 

str.replace(/<[^>]*>/g, '');

 

Please mark my answer as correct and helpful based on Impact.

@newhand  Please let me know in which line i have to insert it. 

@Suvetha S 

It's a hard work... 

Maybe try RaghavSh 's post first is a better way ?

 

I'm sorry , i can't tell you directly where to change it because i don't know, but you can follow the below steps.

Presume the pic points to a portal...

 

1. find out the portal widget which shows the "discription" 

2. if the widgets is read-only...you need to clone the widget/page  to make it modifiable(really complex)...

3. modify the scripts,  add a step to handle the value of "description".

 

 

 

 

Please mark my answer as correct and helpful based on Impact.