无法使用Web服务更新查找字段 [英] Unable to update lookup Field using webservice
问题描述
我已经阅读了许多解决方案,但还无法使用Web服务在列表中填充查找列.
I have read many of the solutions but I haven't yet been able to populate a lookup column in a list using web service.
我在同一站点上有一些名为"ApplicationFamilyList"的应用程序族的列表.
I have a list of some application families named "ApplicationFamilyList" on the same site.
在我当前的列表中,我有一列名为"Appfamily"的类型查找,该列引用了"ApplicationFamilyList".我希望使用webservice-UpdateListItems()方法在该列中插入一些应用程序系列.但是,我
无法填充此列中的项目,可能是由于参考所致.以下是我以声明方式生成的XML.请提出我需要添加到< Field>的哪些属性标记以获取结果.
In my current list I have a column named "Appfamily" of type lookup which has reference to "ApplicationFamilyList". I wish to insert some application families in that column using webservice - UpdateListItems() method. however, I
am unable to populate items in this column maybe due to reference. below is the XML I am generating declaratively. Please suggest what attributes I need to add to <Field> tag to get the results.
string strBatch =
"<Method ID='1' Cmd='New'>
<Field Type='Text' DisplayName='Application_Name' ID='{b475c14a-46ae-495f-b381-d264c2f51a45}'Name='Application_Name'>testApplication1</Field>
<Field Type='Lookup' DisplayName='Application_Family' ID='{bbe858fd-0c8e-406b-a278-83cac0b58d1b}' Name='Application_Family'>testfamilyfamily1</Field>
</Method>";
XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elItem = xmlDoc.CreateElement("Batch");
elItem.SetAttribute("OnError", "Continue");
elItem.InnerXml = strBatch.ToString();
string ListName = "Dev Application Name Lookup";
UpdateSPList.UpdateListItems(ListName, elItem);
提前谢谢!
推荐答案
请在批处理命令中使用查找ID更新查找字段,如下所示:
Please update the lookup field with Lookup Id In the batch Command like below:
<Batch OnError=’Continue’>
<Method ID=’1’ Cmd=’New’>
<Field Name=’OrderDate’ >2007-1-21</Field>
<Field Name=’CustomerID’ Type=’LookUp’ LookUpID=’True’ >2</Field>
</Method>
</Batch>
以下是有关带有批处理更新的更新查找字段的演示,供您参考:
Here is a demo about update lookup field with Batch Update for your reference:
http://dotnetstep.blogspot.sg/2009/01/batch-update-in-sharepoint.html
谢谢
最好的问候
这篇关于无法使用Web服务更新查找字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!