Trouble using .replace() in before business rule on an HTML field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-13-2020 04:53 PM
I have an HTML type field called description. I need to use an onBefore business rule to change a character in the description field. For example: current.description.replace("a","i"); does not work.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-13-2020 05:30 PM
Ensure to set the actual field value through
current.desription = value;
or
current.setValue('description',value); //i tend to prefer this
and
that the correct character (not an 'i' inside and html tag) is being replaced.
Chances are that the better option will be to use a RegEx to ensure the correct value is being replaced in the right location

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-13-2020 06:49 PM
This did not work. Current code updated bellow, still working on this
var desc = current.description.replace(/(<([^>]+)>)/ig, "");
desc.toString().replace(/i/g,'a');
current.setValue('description',desc);