remove unwanted <p> tag from displaying on widget

June Anderson
Tera Contributor

Hi,

 

I have a issue I cannot seem to figure out, I created a widget and this is expected to pull values form. While it works as intended,  I have a <p> displaying along with values from that field. How Can I remove this from showing along with the test 

JuneAnderson_1-1713367142670.png

 

 

 

 

JuneAnderson_0-1713369449468.png

 

4 REPLIES 4

Allen Andreas
Administrator
Administrator

Hi,

This seems to be that the field you're pulling the value from, is an HTML field, thus is has <p> tags, etc.

You'd want to strip the HTML from it then set the field_value to that scrubbed value which will should resolve your issue.

For example, setting a variable to the replaced version like so:

 

var string = "<p>example</p>";
var newString = string.replace(/<\/?[^>]+(>|$)/g, "");

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hey Allen

 

Thank you very much on the response but I don't have any variable I can see from my script 

var string = "<p>example</p>";
var newString = string.replace(/<\/?[^>]+(>|$)/g, "");

 

Should I replace field_value = gr.business_case.replace(/<\/?[^>]+(>|$)/g, "");
field_value;

 

If not to much can you guide me on which I need to replace based on your recommendation please 

 

Thank you 

 

Hi,

You do have a variable, you declared it in your g2 evaluate script...it's called field_value. And you're setting this variable to the value of the business case field on the record retrieved from your gliderecord query.

 

I don't believe you can just add the .replace and so on right to that gliderecord element, which is why I showed an example in my provided script of setting a variable to the value initially, then setting another variable (so you'll need to declare that like you did for field_value) and the previous variable.replace, etc.

 

Let me know if you're still confused, but it was hopeful my example sort of helped explain it a bit more.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

My head is spinning as I am highly confused. Sorry Allen, this is what I got from your explanation

JuneAnderson_0-1713380238287.png