Preserve format of Worknotes entered by User in Record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 03:22 AM
Hello,
I have a requirement where I want to preserve the format of added Work Notes and convert the URLs into clickable hyperlink by user in Demand form.
I have created a business rule before insert update and condition when work notes changes in dmn_demand table. Below is the script:
(function executeRule(current, previous /*null when async*/) {
})(current, previous);
This code is working, however it shows like this below after clicking on Post in Work Notes. It shows us both formatted text and normal text after clicking Post button
Here We want only to display formatted text in Activity Section
https://www.google.com/ Scope ---> 00000
Any insights on what the issue could be in the script would be great. I got this script from one of the community questions on a similar issue but do not have a solution for this.
Thanks in Advance,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 06:50 AM
Hi @Gayathri Ponse1 ,
Try below script in BR.
(function executeRule(current, previous /*null when async*/) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var linkTemplate = '<a href="$1" target="_blank">$1</a>';
var formattedText = current.work_notes.replace(exp, linkTemplate);
formattedText = formattedText.replace(/<\/?[^>]+(>|$)/g, "");
current.work_notes = formattedText;
})(current, previous);
Please mark it as helpful and solution proposed if it works for you.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 07:44 AM
Hi Anand,
Thanks for the response!
However this script is not working. It is not preserving the same format like below. Spaces are not preserved.
https://www.google.com/ Scope ---> 00000
Regards,
Gayathri