extract text from HTML field

giriprasad9
Tera Expert

Hi,

 

I have a custom HTML field in a table. In business rule I want to extract a plain text from that field.

 

In client script I used below code and it is working. But in business rule it is not working. Let me know what I need to do in Business Rule.

 

var html = "<p>Some HTML</p>";
var div = document.createElement("div");
div
.innerHTML = html;
var text = div.textContent || div.innerText || "";

 

Regards,

Giri

4 REPLIES 4

TrevorK
Kilo Sage

I have not had to parse HTML fields for data, however would you not be able to:


a) convert it to a string


b) search for the location of <p> and </p> tags


c) use substring to pull out what is in between



Perhaps one of the more experienced people can help out without having to convert it, however the above is only a couple lines of code and would do the trick if you cannot find something more "pretty".


Hi Trevor,



Thanks for your reply. I have the data in <table> tags. I can't use substring or replace functions to pull the data.


Any other solution is helpful.



Regards,


Giri


Renuka8
Kilo Guru

Hi Giri,




current.FIELDNAME.getHTMLValue();




Replace FIELDNAME with your field element name.


Hi,



Resolved the issue by using regular expressions.


Thanks all for your reply.



Regards,


Giri