- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 01:42 AM
Hi All,
I have a requirement to create a business rule which should copy plain text from Html field("field name: unit_description") and update it to a text filed(field name :"u_so_description")
I created this business rule
(function executeRule(current, previous /*null when async*/) {
var a=current.unit_description.getXHTMLValue();
//to remove HTML text...
a= a.replace(/&(lt|gt);/g, function (strMatch, p1){
return (p1 == "lt")? "<" : ">";
});
var b = a.replace(/<\/?[^>]+(>|$)/g, "");
current.setDisplayValue('u_so_description',b);
})(current, previous);
This business rule is replacing all symbols except &.
For & still i am getting & in plain text.
Kindly help me on this/
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 08:55 AM
Using var c=b.replace(/&/g, '&'); my issue got fixed.
Thanks all for your help
(function executeRule(current, previous /*null when async*/) {
var a=current.unit_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 &
var c=b.replace(/&/g, '&');
current.setDisplayValue('u_so_description',c);
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 01:54 AM
Please check if this helps:
(function executeRule(current, previous /*null when async*/) {
var a=current.unit_description.getXHTMLValue();
//to remove HTML text...
a= a.replace(/&(lt|gt);/g, function (strMatch, p1){
return (p1 == "lt")? "<" : ">";
});
var b = a.replace(/<\/?[^>]+(>|$)/g, "");
var c = b.replace(&, '&');
current.setDisplayValue('u_so_description',c);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 02:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 02:31 AM
Hi Pratik,
Can you check the below link and try it. I have tried for getting the knowledge text in the background script and it is working fine. Can you check it and let us know if it helped?
How to get raw text from HTML field?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 02:34 AM
Please check if this helps:
var c = b.replace('&', '&');