1

In Sharepoint 2010, is there a way to create a new column for a Document Library using the web services API?

1

Yes, you can use the UpdateList method of the Lists.asmx web service. See http://msdn.microsoft.com/en-us/library/lists.lists.updatelist(v=office.12).aspx for more details (this is from 2007, but still works in 2010).

You will basically use XML to add/remove columns using the Field schema. There is a code example on that page.

| improve this answer | |
0

Is using the web service a requirement? Otherwise, you can use the SharePoint CSOM to add a field to a list:

example in javascript:

function addFieldToList() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Announcements');
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'MyField\' Type=\'Number\' />', true, SP.AddFieldOptions.defaultValue);

var fieldNumber = clientContext.castTo(oField,SP.FieldNumber);    
fieldNumber.update();

clientContext.load(oField);

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

}

Refer to this MSDN page for more info about the javascript CSOM or to this page for the .NET version.

| improve this answer | |
  • 1
    Thanks for the response. The requirement is to make the call from a Java application so using the web service appears be best. – Reynard Jan 17 '14 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.