Juhi Poddar
Kilo Patron

Hello @venkram 

I agree with @Ankur Bawiskar . When we directly add the test string, it works as expected. The issue arises when retrieving the value from the short description, where it doesn't behave as anticipated.

To resolve this, I first encoded the string and then replaced the encoded values for \n and \r (%255Cn and %255Cr) with an empty string.

You can try the following script:

var gr = new GlideRecord('cmdb_ci_ip_firewall');
gr.addQuery('name', 'Test01'); // Correct query for the record
gr.query();

if (gr.next()) {
    var desc = gr.getValue('short_description');
    var encodedString = encodeURIComponent(escape(desc));
    //gs.print(encodedString);
    var cleanedDesc = encodedString.replaceAll('%255Cr', "").replaceAll('%255Cn',"");
    gs.print(cleanedDesc);
    gr.setValue('short_description', cleanedDesc);
    gr.update();
}

Result:

JuhiPoddar_0-1735984097506.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

Thank You!
Juhi Poddar