2

I am attempting to store snippets of HTML in a Multi-Line text field. This field is a hidden field which I read and write to using REST in an app I am building that allows the user to manipulate a tree graph without having to open an html file just by dragging and dropping nodes. So far it's working great with one small oddity I can't seem to get around.

To me Plain Text means PLAIN text but if I were to add...

https://google.com

... to my Multi-Line text field, save it, and reopen the edit screen, I find that Sharepoint has converted it to an anchor tag and reads...

<a href="https://google.com">https://google.com</a>

I understand why they have this functionality if you're using the field in a standard out of the box way but it becomes particularly troublesome if I want to store an actual anchor tag as text to later be used in my graph because...

<li>
    <a href="https://google.com">Click Here to get to Google!</a>
</li>

...becomes...

<li>
    <a href="<a href="https://google.com">https://google.com</a>">Click Here to get to Google!</a>
</li>

... which makes no sense and breaks the link.

I have also noticed that adding a local link like...

https://mysharepointsite.com/path/to/location

... automatically gets "relativized" down to...

/path/to/location

... This is just so annoying as there are times I want to include these links in outlook email body's and obviously a relative link means nothing in an email body because it has lost the host info. But that is another issue all together.

So my question is. How do you tell SharePoint to quit messing with my text? In any other Database I can think of there are way's to escape or sanitize text... SharePoint has GOT to have something similar right? Please help.

It might be important to note that any text saved to this field will be added via javascript using REST api. The field will be completely hidden to any human for manual editing.

2 Answers 2

2

Here is my solution as it stands... Every time I am writing to Sharepoint with a POST I run this on my payload...

htmlToAdd = htmlToAdd.replace(/https:\/\//, '$sharepointsucks$');

and right after I retrieve the html with a GET I run this...

loadedHtml = loadedHtml.replace(/\$sharepointsucks\$/, 'https://');

That way Sharepoint leaves my text alone as it cannot detect urls since...

$sharepointsucks$google.com

...is not a url. So freaking stupid...

If anyone can come up with a better answer than I will change my answer to yours since this is really just a hack.

0

You need to select Plain Text in option "Specify type of text to allow".

Please refer screenshot below. https://snag.gy/aR3DBc.jpg

Go to List settings - Edit column(multi line of text field) - Select Plain Text (as mentioned in above screenshot).

3
  • 1
    Thanks but as I mentioned in my post I am already using plain text. That is not the issue.
    – Riggy
    Commented Nov 30, 2016 at 19:02
  • then it should not...I already tried it is not converting anchor..it keeps all html as simple text format....Refer to snag.gy/oqTJPp.jpg and snag.gy/TtBiwI.jpg Commented Nov 30, 2016 at 19:07
  • You see how the text inside your href attribute is blue in your second screen shot? That's because its a hyperlink... if you open it in Quick Edit mode you will see that it is how I am describing. But more importantly I am referring to how it is returned in a REST call.
    – Riggy
    Commented Nov 30, 2016 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.