12

I have a list in SharePoint 2010 and it has got a multiline text field with Enhanced HTML enabled.

When I create a hyper link pointing to

http://servername/site

and save it, SharePoint converts this absolute URL to a relative URL and changes link to /site which is wrong.

Update:

We use this list to store email templates to be merged with correct data from other list and send it.

Basically, just an example: Dear "User" please view your user dashboard by clicking on

"http://intranetservername/site"

SharePoint changes this link to /site when saved. So it might be a preferred behavior, but surely there should be a way to override it?

Is there any way to disable this?

  • 4
    This is actually the preferred behavior in SharePoint and on the web in general. Is there a reason that you need to full URL to remain? – Dave Wise Mar 22 '13 at 18:05
  • What is the URL you are entering in and what is the result? May need to also explain your site structure so we can tell why the resulting url is wrong. – Ryan Erickson Mar 22 '13 at 22:33
  • @DaveWise we have email templates in one of the SP lists and we embedded some links into these templates. let's say you have got a template sayind that please go to this link to access your tasks. and make "this link" is absolute. However, it is converted into relative url which makes link broken. – AnarchistGeek Apr 2 '13 at 12:33
  • 1
    It used to be that it would only strip the server name when you used the Rich Text editor to create the hyperlink and creating fully qualified URLs could be done if you switched to editing the raw HTML and created the href that way. I haven't tried this in a while nor do I recall if it kept the change across subsequent edits but that was a workaround. – Dave Wise Apr 2 '13 at 14:39
  • 1
    How are you using the data? Do you have a SP hosted program that reads it and send it? or a workflow? In either case, you will need to find a method of creating the links at the time you send the email, rather than depending on them being stored in the RTE field. Also: have you tried using a plain text multi-line field to store strait HTML? – Paul T. Nov 28 '13 at 14:52
2

Unfortunately like Dave Wise has said, that's the intended behavior. You might be able to use SPSite.MakeFullUrl() to convert it back, but from what I remember it doesn't handle https particularly well.

I think it does http://:443 which clearly won't work if it isn't on port 443!

  • we are a big technology company and when I told my users that this is intended behavior, they laughed at me:) – AnarchistGeek Mar 27 '13 at 9:49
  • 3
    Then they don't understand SharePoint. In SharePoint, a single content database can have up to 5 default URLs and any number of alternate URLs. If it embedded the full path to the one specific server name in the hyperlink then that same content would be broken when viewed from another URL. Imagine an Extranet scenario where the same content is referenced internally as myinternaldomain/site but externally as external.company.com/site. Not only would URLs in the first format be utterly useless to extranet users but it would also violate many company security policies. – Dave Wise Apr 2 '13 at 14:35
2

We have the same issue. In our case, we are using a workflow to dump out the data to SQL Server for use in a reporting engine. The problem is that in the reporting engine, relative URLs are useless. To get around this, we have to fire something off in SQL Server to pre-pend the missing URL parts. Our workflow reads the SP list item, transfers the contents to SQL Server which then makes the data visible to Cognos. Cognos has no clear way to read the SP list directly and we are not allowed to use SSRS by Corporate mandate, hence the need to transfer the data to SQL. Once the data hits SQL Server, a local Stored Proc then scans the text field and looks for relative URLs and pre-pends the missing part(s). Why? Because in this text field, users want to be able to insert images from an Image Library on SharePoint, but still see them render in Cognos. It isn't pretty, let alone elegant, but it works.

1

I had encountered this issue as well when I was storing email templates that a Workflow would use to send out emails.. My use case was that a Workflow would read the email template and then include it in the body of the email message... I was using SP2007. My work-around was to build the Links in the workflows itself and then add them to the template... Because workflows (SP2007) did not have a "String.Replace()" type of action, I had to break up my email template into "sections" that I then concatenated together around the url's that were created.. Not an easily maintainable solution, but its working to this day...

I don't remember if I did this or not back when I implemented the solution mentioned above, but try building your links in a more creative way. For example: instead of a strait "http..." link, do something like:

javascript:window.location.href='http://intranetservername/site'

or

javascript:window.location.href='http://' + 'intranetservername/site'

This might work... not sure how Outlook or any other email client will react to these types of urls... they may block them.

1

convert that Multiple Lines of Text field to plain text instead and type html tags by hand.

in my scenario which i had a few email templates it was possible.

  • This worked for me. I was creating the list item via JSOM and then it was emailing out. So I already had my code at HTML – Bryan Mathews May 19 '15 at 18:51
1

My problem was about the images and then this javascript does not worked for me. I am sending an e-mail and the urls are getting replaced by the wrong urls as explained. I used the Googler Shortener, it't not beautiful but it works for me.

  • Awesome solution!!!! – Aaron Jan 3 '17 at 15:07
0

Same problem here. We have an enhanced richtext field in SP2010 that is used as a template for the body of emails we send. If the field contains a hyperlink to anything on the sharepoint farm, the editor itself converts the url to a relative one before you can even save the list item.

If you were to make the change using code or script, it would probably work. If you can't do that, you could use one of the free redirect services on the internet like tinyurl.

If setting it programmatically works, you could add an event handler to the list to re-expand the relative URLs to absolutes and then commit the change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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