Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've written an app that reads data via the web services in order to help my data migration process from SharePoint 2007 to 2010. I've been successful for the most part. I've been able to bring the users over even though it's a completely different farm from the following technique.

  <Batch OnError="Continue"> 
    <Method ID="2" Cmd="Update"> 
      <Field Name="ID">5</Field> 
      <Field Name="Title">Efghijk</Field> 
      <Field Name="AUserField">-1;#Jack Kirby</Field> 
      <Field Name="AnotherUserField">-1;#Stan Lee</Field>     
    </Method> 
  </Batch>

So that has helped greatly, however I am having no success with it comes with a Linked File Field or Notes field with Richtext. I am successfully retrieving the data from via the 2007 web services connection but I'm just not able to send to 2010 into an identical field type. There are no errors, it's like it just ignores the data.

Now concerning the field link, I have gone as far as taking the existing SP 2007 field link data and stripping it down to match the required look and feel that MS has stated.

"<A href=\"/Documents/SampleFile.docx\" target=\"_blank\"><IMG src=\"/_layouts/images/icdoc.gif\" alt=\"\">Open [SampleFile.docx] in a new window</a>";

MS Reference Link For Above

However when I follow the above example i get an error when adding the method when building my Batch Statement. It's always something and it's usually different per Batch Method. Currently it's about 1000 records per list that I'm trying to bring over with each one erroring out.

So I thought I would clean it and that comes over successfully but is inserted into the field like this...

%3ca+href%3d%22http%3a%2f%2fmy.magicalsite.com%2fasubsite%2falibrary%2fA%20file%20Link.pdf%22%3e%3cimg+alt%3d%22%22+border%3d0+src%3d%22%2f_layouts%2fIMAGES%2fpdficon_small.gif%22+class%3dms-asset-icon%3eA%20file%20Link.pdf%3c%2fa%3e

And that simple looks like a bunch of garbled text in the link field, invalid of course.

Here is an example of what a value should look like from the source page. I added this in manually as a new field link in SP2010.

<a href="http://my.magicalsite.com/asubsite/alibrary/A%20file%20Link.pdf">A file link.pdf</a>

CAN ANYBODY PLEASE HELP ME FIGURE OUT HOW TO FORMAT A FIELD LINK FIELD VALUE THAT THE WEB SERVICE WILL ACCEPT? No, Link,Description does not work, trust me I've gone through every single possible way to format the dang thing and it either won't come across or ends up as invalid useless text. I need these links....

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Have your tried perform encoding your values using SPHttpUtility Class. For example, you can use SPHttpUtility.HtmlUrlAttributeEncode to encodes the specified string for use as an attribute value for URL type attributes, such as the href attribute of an anchor tag or the src attribute of an image tag.

share|improve this answer
    
No I have not tried that and I will try later today and let you know if that works, appreciate the help. –  Patrick Jun 2 '12 at 17:19
    
I had to modifiy your suggestion a bit as I'm not using any of the SharePoint Dlls, strictly Web Services but it worked using the following...... string url = HttpUtility.HtmlAttributeEncode(_attValue); However the icons for say, the pdf files are all red X's so i'll either have to figure that one out or just accept it. I don't care as I just wanted the links (THANK YOU!) but my end users will want the clean look and feel of icons to their links (THANK YOU!)....hehe –  Patrick Jun 2 '12 at 17:36
    
I will look into using some of the HttpUtility Methods to encode Richtext fields, unless you have any input on that as well! –  Patrick Jun 2 '12 at 17:37
    
Excellent and great to know it turned out well for you :) –  Falak Mahmood Jun 2 '12 at 21:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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