开发者

Uploading files to Sharepoint list + setting values for Lookup-type column

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_NAM开发者_开发问答E) + "\\" + (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


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜