Flow Designer - Transform Function - Replace string not working on HTML field type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 12:43 PM
Hi,
I am working on a payload for an API call and need to add an exit character before every ' (apostrophe).
I'm using flow designer and successfully used the "replace string" transform function for string fields but now am working on doing the same thing for a HTML field.
so for an example.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 03:29 PM
Hi @CStaples yes, got it working in the end after some fiddling around with code. Wasn't the cleanest code, but it worked, and we went live with the story just before Christmas. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 10:31 AM
@Ben28 Thanks Ben! I'd be very curious to hear about your solution through Flow Designer. I have personally been working on piecing this whole situation together. Currently the two challenges I'm working with:
1) The Meeting_Notes field getting overwritten by the OOB Script Include: CABAgendaItemSNC
2) The HTML tags getting added to the Meeting_Notes field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 11:31 AM
var ptaskfixstatement = "This Problem Task (PTASK) is for tracking the implementation of Corrective and Preventive Actions (CAPA) identified in the Root Cause Analysis (RCA).\n" +
"The task may be reassigned to the team or individual responsible for executing the CAPA actions.\n" +
"If needed, additional PTASKs can be created to support further actions.\n";
var htmlString = fd_data.trigger.current.fix_notes;
const plainText = decodeHTML(htmlString);
combinedText = ptaskfixstatement + plainText;
return combinedText;
function decodeHTML(str) {
var a = str.replace(/<br\s*\/?>|<p\s*\/?>|<\/?(ul|ol|li)\s*\/?>/gi, '\n'); //Retain line breaks & replace bullet & number lists with new line.
var b = a.replace(/<\/?[^>]+(>|$)/g, ""); //Remove tags
var c = b.replace(/&/g, '&'); //Retain any ampersands that are just ampersands
var d = c.replace(/\n+/g, '\n'); // combine multiple line breaks into 1.
return d.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec); //Returns the special character from the decimal code representation and returns the entire decoded string.
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 12:11 PM
Thanks for sharing Ben! I think I'm going to continue the course with the Flow Data Transformation Pill rather than a scripted approach. I appreciate having this as reference in case I run into any walls.