Stripping HTML from 1 field to another as part of a flow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2024 02:54 PM
I'm trying to create a flow, so when a Problem moves from RCA, a new PTASK is opened, and assigned to the Problem Owner to implement to corrective actions identified in the Fix Notes. I'm trying to pull fix_notes, (which is HTM enabled) from the Problem, and copy it to the PTASK description (which his plain text). I can get the fix_notes content to copy, but it comes over with all the html tags (<p>, < /br> etc.). I tried using a replace string transform function, within the flow, and using a regex to replace the string, but this results in a glide error when testing: com.glide.glideobject.GlideHTML@1e34d97. Is a transform the correct way to do this,, and if so, how, or is there a better way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2024 08:52 PM
Hi @Ben28
Refer below post and try the solution provided by Mak :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2024 09:21 PM
Tried with transformation function as well. Somehow, Replace String doesn't seems to work with html tags. Found an alternative and easy way to fix this. Please refer below steps :
1. Suppose I have a flow variable in which HTML is stored :
2. To get rid of the HTML tags, we will make use of Scripting and regex. With replace function, we will replace the HTML tags with a null :
var htmlString = fd_data.flow_var.accountnametocreate;
var plainText = htmlString.replace(/<[^>]+>/g,'');
return plainText;
Output :
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2024 08:40 AM
Hi, thanks for this, I got it somewhat working using "var htmlString = fd_data.trigger.current.fix_notes;" to pull the fix_notes details, and strip off the html. However, it is possible to replace the html line breaks with carriage returns? What I end up with currently, is 3 lines of HTML, all combined into 1. For example:
Corrective Action/Preventive Action Plan: Install more server memory
Change Required?: Yes/No
Tentative Implementation date:
Becomes:
Corrective Action/Preventive Action Plan: Install more server memoryChange Required?: Yes/No Tentative Implementation date:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2024 04:15 PM - edited ‎09-25-2024 04:16 PM
OK, think I got this working now. Had to add a new regex expression to replace <br> and <p> with /n first.
var ptaskinstructions = "This PTASK is to track CAPA Implementation.\n" +
"It can be reassigned to the team & person responsible for Implementation the actions identified in the RCA.\n" +
"Additional PTASKs can be created if required.\n";
var htmlString = fd_data.trigger.current.fix_notes;
const plainText = decodeHTML(htmlString);
//var plainText = htmlString.replace(/<[^>]+>/g,'');
combinedText = ptaskinstructions + plainText;
return combinedText;
function decodeHTML(str) {
var a = str.replace(/<br\s*\/?>|<p\s*\/?>/gi, '\n'); //Retain line breaks
var b = a.replace(/<\/?[^>]+(>|$)/g, ""); //Remove tags
var c = b.replace(/&/g, '&'); //Retain any ampersands that are just ampersands
return c.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.
});
}