HRSD Record Producer text box cannot receive special characters

nseabra
Tera Contributor

Hi all,

 

I have a record producer that has 5 variables, all of them are "Multi Line Text". This variables are then populating the description of the respective HR Case.

I'm facing an issue where, whenever an user types some special characters ("", <, >, &,...), these characters are replaced with HTML code (See images). 

nseabra_0-1690883511263.png

nseabra_1-1690883539636.png

 

 

Is there a workaround that allows the description to be populated with the special characters?

 

Thank you all 🙂 

 

1 ACCEPTED SOLUTION

Hello @nseabra 

 

You can use this :-

 

setStringParameterNoEscape

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

View solution in original post

11 REPLIES 11

Hi @Samaksh Wani,

 

Your answer helped a lot, however, it was not what I was looking for. The line of code that "did the trick" for me was:

GlideStringUtil.unEscapeHTML(gr.short_description);

 

 

Moreover, the method unEscapeHTML(); is documented as replacing the following special characters "<>&. 

But when I used it, the special characters were indeed printed, but not the "" .

I don't know why it is still happening.

 

Thank you,

Nuno

Hello @nseabra 

 

You can use this :-

 

setStringParameterNoEscape

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

Mahesh23
Mega Sage

Hello,

There seems to be a bug in an HR (HRSD) Business Rule named "Sync description with rich_description." The situation involves the presence of two description fields in the HR Case table:

  1. Description [An HTML-type field].
  2. Description [A String-type field].

When you submit a record producer associated with an HR Category, such as an HR Report Request, the function createCaseFromProducer() in hr_ServicesUtil() combines the variable answers and generates a new description. This new description is then placed into the Description field (which is of HTML type). Subsequently, the Business Rule named "Sync description with rich_description" copies the content from the Description field (HTML type) to the Description field (String type).

An issue arises when the variables contain special characters like "@", "#", and "". When the content from the HTML-type Description field is copied to the String-type Description field, these special characters are displayed as HTML numeric values (encoded values), instead of their actual intended values. This discrepancy occurs because the content copied to the String-type Description field retains HTML formatting, causing these special characters to be displayed as HTML-encoded numeric values.

Update below Business Rule as below:
https://www.XXXXXX.service-now.com/sys_script.do?sys_id=8858040c53672300ff25ddeeff7b1229

From:

(function executeRule(current, previous /*null when async*/) {
	current.description = current.rich_description;
})(current, previous);


To:

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

    var richDesc = current.rich_description;
    var escapedString = richDesc.replace(/<[^>]*>|&#(\d+);/g, function(match, dec) {
        return dec ? String.fromCharCode(dec) : '';
    });
    current.description = escapedString;
})(current, previous);

 

Thank you Mahesh it was helpful.

We noticed this issue after Utah upgrade. This is OOB BR and its surprises me as we never faces issue before and started only after our upgrade.

Do you know why it was working before

Hey,
Good day
No, I have no idea