zoukankan      html  css  js  c++  java
  • 深入浅出SharePoint——批处理高效导入数据

    If you are using the Lists.asmx web service the hyper link column must be in the format of "link, description". For example http:\\www.whatever.com, nice site. The user column must be in the format of ID;#Domain\UserName. So you will need to construct this. You can get this information calling the UserGroup.asmx webservice's UserInfo method. Below is example code of populating a list with a new item using a user and hyperlink column:

      listservice.Lists listProxy = new listservice.Lists();

                string xml = "<Batch OnError='Continue'><Method ID='1' Cmd='New'><Field Name='ID'/><Field Name='usercol'>1;#BASESMCDEV2\\steve.curran</Field><Field Name='hyperlinkcol'>http://www.certdev.com, cool site</Field></Method></Batch>";

                XmlDocument doc = new XmlDocument();

                doc.LoadXml(xml);

                XmlNode batchNode = doc.SelectSingleNode("//Batch");

                listProxy.Url = "http://basesmcdev2/sites/tester1/_vti_bin/lists.asmx";

                listProxy.UseDefaultCredentials = true;

                XmlNode resultNode = listProxy.UpdateListItems("custom1", batchNode);

    http://www.certdev.com

    Marked As Answer byjdxyw Thursday, April 16, 2009 1:35 AM

    Steve.Curran  Wednesday, April 15, 2009 3:43 PM

    To Store values to User Field and URL Field, we have to store in differentformat.

    Because the The User Field is a Lookup Field, getting value from User Information List. The URL Field contains two values, one for URL and another one for URL Description.

    User Field Format: [ID];#[User Login Name]

    URL Field Format: [URL], [URL Description]

    Below i give the sample code for addng new list item with URL and User Fields,

    UserGroupWebService.UserGroup ugService=new UserGroupWebService.UserGroup();

    ListsWebService.Lists lService=new ListsWebService.Lists();

    //Get User ID from User Login Name

    XmlNode ugNode=ugService.GetUserInfo("Server\\LoginName");

    XmlDocument ugdoc = new XmlDocument();

    ugdoc.LoadXml(ugNode.OuterXml);

    XmlNodeList ugList = ugdoc.GetElementsByTagName("User");

    string id = ugList[0].Attributes["ID"].Value;

    //Build the xml for adding new list item

    string strBatch = @"<Method ID='1' Cmd='New'>

    <Field Name='Title'>Sample Title</Field>

    <Field Name='UserName'>" + id + @";#SERVER\\LoginName</Field>

    <Field Name='SampleUrl'>http://www.microsoft.com, Microsoft Site</Field>

    </Method>";

    XmlDocument xmlDoc = new System.Xml.XmlDocument();

    System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");

    elBatch.InnerXml = strBatch;

    //Addding item to the List

    XmlNode ndReturn = lService.UpdateListItems("<List Name>", elBatch);

    Before coding add the (~site/_vti_bin/Lists.asmx and ~site/_vti_bin/UserGroup.asmx) webservices as references.

    SPFieldUrlValue urlValue = new SPFieldUrlValue();

                        urlValue.Url = items.First().Value.ToString();

                        urlValue.Description = "Link";

                        itemValue =  urlValue.ToString();

    http://www.sharepointdev.net/sharepoint--development-programming/how-to-use-web-service-to-add-a-new-item-which-has-a-hyperlink-column-a-user-column-53394.shtml

  • 相关阅读:
    2005226考勤登记
    2005219考勤登记
    2005225考勤登记
    2005224考勤登记
    2005222考勤登记
    116道iOS面试题+答案,希望对你的面试有帮助
    在线代码编辑器(Ace)被防火墙误杀
    使用Certbot实现阿里云泛域名证书的自动续期
    实时音视频入门学习:开源工程WebRTC的技术原理和使用浅析
    百善孝为先
  • 原文地址:https://www.cnblogs.com/mingle/p/2807695.html
Copyright © 2011-2022 走看看