When copying HTML field to journal field using Client script Tags are getting copied?Tags to remove?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 11:28 PM
When copying HTML field to Journal field using Client script Tags are getting copied?
How should we remove tags and copy only content from HTML field to Journal field using Client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 11:37 PM
hello @VIKAS45 ,
Put your HTML code inside [code] tag and then try to populate it in journal field
Example:
[code]<a href="http://www.service-now.com">ServiceNow</a>[/code]
Also before using code tag you need to check if this property is set to true in your instance in system properties table
glide.ui.security.codetag.allow_script - should be true
Hope this helps
Mark my answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 11:39 PM
Hi @VIKAS45 ,
When copying content from an HTML field to a Journal field using a client script, you want to remove any HTML tags and copy only the plain text content. Here's how you can achieve that:
Assuming you have an HTML field named html_field and a Journal field named journal_field, you can use this code as
// Get the HTML field value
var htmlFieldValue = g_form.getValue('html_field');
// Remove HTML tags using a regular expression
var plainTextContent = htmlFieldValue.replace(/<[^>]*>/g, '');
// Set the plain text content to the Journal field
g_form.setValue('journal_field', plainTextContent);
In this script:
g_form.getValue('html_field') retrieves the value from the HTML field.
The regular expression /<[^>]*>/g matches HTML tags in the text.
.replace(/<[^>]*>/g, '') replaces all occurrences of HTML tags with an empty string, effectively removing them.
Finally, g_form.setValue('journal_field', plainTextContent) sets the plain text content to the Journal field.
If you find my response helpful in solving your query, please consider liking and marking my reply as the solution.
Thank you,
Ismail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 05:43 AM
Thank you Ismail How to remove   for space in HTML field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 06:20 AM
You can do this by using this piece of code
var plainText = htmlContent.replace(/<[^>]+>/g, "").replace(/ /g, " ");
Please like and Mark my answer correct if this helps you
Thanks