- 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 06:03 AM
I tried this also but not able to achieve.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 08:39 AM
- 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
‎07-30-2020 09:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2020 12:40 PM
Disregard, i was able to modify my code slightly to produce the desired results. Your answer was helpful in getting me there. Thank you.
var a = current.description.getDisplayValue();
//to remove HTML characters.
a = a.replace(/&(lt|gt);/g, function (strMatch, p1){
return (p1 == "lt")? "<" : ">";
});
var b = a.replace(/<(?:.|\n)*?>/gm, '');
//to remove &
var c = b.replace(/&/g, '&');
var d = c.replace(/ /g, '');
current.setDisplayValue('description',d);