Remove HTML tags and display images on UI Page

AnaBeatrizA
Tera Guru

I'm workint with an UI Page that uses an UI Macro as template and I need to display the values from another table.
As the field has HTML type, I need to remove the html tags and show the attached images also.
I'm trying to use replace(/./g, '') but my code is not working.
Does someone knows how to do this?
Here's my code:

<div class="panel-body">

<h3>Test Instructions</h3>
<span uib-tooltip="$[jvar_test.getValue('u_test_instructions')].replace(/./g, '')" tooltip-placement="bottom-left" tooltip-append-to-body="true"  class="test-description text-ellipsis">$[jvar_test.getValue('u_test_instructions')].replace(/./g, '');
</span>
 </div>

Thank you!!
Ana

2 ACCEPTED SOLUTIONS

Hi Seja, I was able to resolve it. Using no_escape

<div class="panel-body">
                            <h3>Test Instructions</h3>
                            <g:evaluate var="jvar_test_instructions">
                                var test_instructions = "$[jvar_test.getValue('u_test_instructions')]";
                                test_instructions;
                            </g:evaluate>                            <g2:no_escape>${jvar_test_instructions}</g2:no_escape>                        </div>

View solution in original post

AnaBeatrizA
Tera Guru

I was able to resolve it using no_escape.

View solution in original post

4 REPLIES 4

sejal1107
Tera Guru

Hi @AnaBeatrizA

can you try with replace(/\./g, ""); instead of replace(/./g, "");

or Use replace(/<[^>]*>/g, ''); instead of replace(/./g, '');
This will remove only HTML tags while keeping the text content.

 

Please mark helpful and solution accepted if it helps.

Thanks & Regards,

Sejal

Please check and Mark Helpful and Correct if it really helped you.
Thanks & Regards
Sejal Chavan

Hi Seja, I was able to resolve it. Using no_escape

<div class="panel-body">
                            <h3>Test Instructions</h3>
                            <g:evaluate var="jvar_test_instructions">
                                var test_instructions = "$[jvar_test.getValue('u_test_instructions')]";
                                test_instructions;
                            </g:evaluate>                            <g2:no_escape>${jvar_test_instructions}</g2:no_escape>                        </div>

Ankur Bawiskar
Tera Patron
Tera Patron

@AnaBeatrizA 

Please share the complete script

what are you trying to render from field "u_test_instructions"?

Is that field HTML type?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

AnaBeatrizA
Tera Guru

I was able to resolve it using no_escape.