Webs.UpdateColumns Web Service
I'm tying to change the DisplayName of the Title site column in my sharepoint site. The column was renamed and now I want to change it back to Title but you can't do it through the UI because SP whines about that column name already existing or being a reserved name. I don't have access to the server, so I can't use Power Shell or the object model to update the column. I'm trying to use the Webs.UpdateColumns web service to do my bidding, but I keep getting 0x80004005 Operation Failed
errors. This is the code I'm using.
var soapEnv =
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
<soap:Body> \
<UpdateColumns xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<newFields><Fields /></newFields> \
<updateFields> \
<Fields><Method ID='1'><Field Type='Text' Name='Title' DisplayName='Title'></Field></Method></Fields> \
</updateFields开发者_开发技巧> \
<deleteFields><Fields /></deleteFields> \
</UpdateColumns> \
</soap:Body> \
</soap:Envelope>";
$.ajax({
url: "http://moss.local/_vti_bin/webs.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
contentType: "text/xml; charset='utf-8'",
complete: function(xData, status) {
console.log(status);
console.log(xData.respnseText);
console.dirxml(xData.responseXML);
}
});
And this is the response I get back:
<soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:body>
<updatecolumnsresponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<updatecolumnsresult>
<results>
<newfields></newfields>
<updatefields>
<method ID="1">
<errorcode>0x80004005</errorcode>
<errortext>Operation Failed</errortext>
</method>
</updatefields>
<deletefields></deletefields>
</results>
</updatecolumnsresult>
</updatecolumnsresponse>
</soap:body>
</soap:envelope>
Any ideas one what would be causing the failed result?
Well, I didn't find out why I was getting an operation failed error, but I found a solution to my underlying rename problem. Turns out SP doesn't do a server-side check for conflicting column names on FldEdit.aspx, so removing the client-side check allowed me to rename it.
I navigated to the site column page, saved it to my local disk, changed this block of code
if (doesFieldNameConflict(DisplayName))
{
alert(L_alert3_Text);
frm.DisplayName.focus();
return false;
}
to this
if (doesFieldNameConflict(DisplayName))
{
//alert(L_alert3_Text);
//frm.DisplayName.focus();
//return false;
}
opened the file and proceeded to change the column name like normal.
Just thought I'd comment on this old post in case anyone ever needs the information.
The update field method requires the Type and Name attributes. The DisplayName attribute is listed as optional, but when missing the method also fails.
However, here the problem might have been related to trying to modify the Name attribute, which isn't possible.
Here is what Microsoft says about the Name attribute:
Required Text. The name of a field. This is the internal name of a field and is guaranteed never to change for the lifetime of the field definition. It must be unique with respect to the set of fields in a list. The name is autogenerated based on the user-defined name for a field.
Attribute Reference:
http://msdn.microsoft.com/en-us/library/ms437580(v=office.12).aspx
精彩评论