views:

31

answers:

1

Hi all,

I'm using Sharepoint's Copy.asmx webservice to upload legacy files and their metadata. The target is a custom list (with nested folders and custom fields - all as text - ).

The file upload is ok, their metadata is ok, CAML querying is ok,but....

One of my custom attribute is the doc_type. Due to time constraints I set this also as text. However if users start creating their own content, I'd prefer to maximize data sanity by using this doc_type as a Lookup field instead of free text.

I'd appreciate some help on how to set the FieldInformation collection properly.

It's overkill to post the whole code, but here is the pertinent portion. I start to create a detailed XML that represents every folder and file. The "file" node contains, as attributes, the metadata. This block of code is iterating over each node's attributes.

    foreach (XmlAttribute attr in node.Attributes) {
        if (attr.Name.StartsWith("c_")) {
            spfinWSCopy.FieldInformation fi = new spfinWSCopy.FieldInformation();
            fi.DisplayName = attr.Name;
            fi.InternalName = attr.Name;
            fi.Type = spfinWSCopy.FieldType.Text;
            fi.Value = attr.Value;

            spfields.Add(fi);

    }
}

In the end, the WS is called using:

                copyService.CopyIntoItems(destination
                                         , destinationURL
                                         , file.spfieldInfo
                                         , File.ReadAllBytes(AppSettings.getAppPropertyValue(CConstants.SOURCE_FOLDER_KEY_NAME) + "\\" + (file.destinationFolder).Replace("/","\\\\") + file.name)
                                         , out result);

Sorry for the long intro. The question is: how should I rewrite the following for Lookup fields?

    fi.Type = spfinWSCopy.FieldType.Text;
    fi.Value = attr.Value;

Thanks, Pedro

A: 

To whom it may interest, I found that I cannot set Lookup fields using webservices, in another thread in SO.

This link elaborates a bit. Quite frustrating, I'll check my business requirements, I may have to go into RPC.

Thanks for listening, anyway :)

pfonseca
Update info, for the sake of information case someone bumps into the same issue: Although I cannot set Lookup-type fields using webservices I CAN set Choice-type fields! My problem is now solved. Reminder: my goal is to sanitized user input.
pfonseca