We have a SPFx project to retrieve SharePoint online event Calendar list items. The "Description" field for the calendar is out of box bind to event content type that is multiple line rich text that we cannot change to "pure text".
When we retrieve using pnp/sp and then display, the description content displays as something with html tags below.
_ This is the test meeting
Is there anyway we could display as text not with html tag?
The code is just like below.
sp.web.lists.getByTitle("PubsMeeting").items. get().then((response) => {
replyList = response;
for (let i = 0; i < replyList.length; i++) {
console.log("Description = " + replyList[i].Description);
// output is like this:
// **_<p>This is the test meeting<br></p>_**
}
});
Thanks in advance for your suggestions!
Yes, sure... create a temporary element, set the innterHtml of that element to the contents of the field and then take the innterText value of the element to get plain text.
let dummyElement = document.createElement("DIV");
dummyElement .innerHTML = replyList[i].Description;
let outputText = dummyElement.innerText;
Thanks for the quick response. Let me try.
Appreciated your suggestions!!!
Yes and yes. This works!!!
Thanks again for your help!!!
Thank You much @juliemturner ! :)
Most helpful comment
Yes, sure... create a temporary element, set the innterHtml of that element to the contents of the field and then take the innterText value of the element to get plain text.
let dummyElement = document.createElement("DIV");
dummyElement .innerHTML = replyList[i].Description;
let outputText = dummyElement.innerText;