Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
UpdateContentType Method

Lists.UpdateContentType Method

Windows SharePoint Services 3
Updates the specified list content type.

Web Service: ListsWeb Reference: http://<Site>/_vti_bin/Lists.asmx

'Declaration
<SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/UpdateContentType", RequestNamespace:="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace:="http://schemas.microsoft.com/sharepoint/soap/", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Function UpdateContentType ( _
	listName As String, _
	contentTypeId As String, _
	contentTypeProperties As XmlNode, _
	newFields As XmlNode, _
	updateFields As XmlNode, _
	deleteFields As XmlNode, _
	addToView As String _
) As XmlNode
'Usage
Dim instance As Lists
Dim listName As String
Dim contentTypeId As String
Dim contentTypeProperties As XmlNode
Dim newFields As XmlNode
Dim updateFields As XmlNode
Dim deleteFields As XmlNode
Dim addToView As String
Dim returnValue As XmlNode

returnValue = instance.UpdateContentType(listName, contentTypeId, contentTypeProperties, newFields, updateFields, deleteFields, addToView)

Parameters

listName

A string that represents the name of the list on which the list content type resides.

contentTypeId

A string that represents the content type ID of the list content type to be updated.

contentTypeProperties

A string that represents the properties to update on the list content type.

Format the properties as a ContentType element, and include the element attributes for the properties you want to update.

newFields

A string that represents the collection of columns to add to the list content type.

Format the column collection as a FieldRefs element, where each FieldRef child element references a column to add to the list content type.

updateFields

A string that represents the collection of columns to update on the list content type.

Format the column collection as a FieldRefs element, where each FieldRef references a column to update on the content type.

In each FieldRef child element, include the element attributes for the column properties you want to update.

deleteFields

A string that represents the collection of columns to delete from the list content type.

Format the column collection as a FieldRefs element, where each FieldRef references a column to delete from the content type.

In each FieldRef child element, include the ID attributes for the column you want to delete.

addToView

A string that represents whether or not to add the content type columns to the list view. Specify true to add the columns to the list view, false to keep the columns hidden.

The following example updates the description of the specified list content type, and then displays the method results in a dialog box.

Imports System.Xml
Imports System.Web.Services.Protocols
…
Public Sub UpdateListContentType()
  Dim listService As New Web_Reference_Folder.Lists
  listService.Credentials = System.Net.CredentialCache.DefaultCredentials

  Dim listName As String = "listName"
  Dim contentTypeId As String = "0x010100C78DE4D7C0C57C43AF878D28256599CA002E1A80DF76000C4780E09DDFFB90076D"
  Dim ctDescription As String = "Enter new list content type description here"
  Dim xmlDoc As New XmlDocument
  Dim xmlFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Fields", "")
  Dim xmlProps As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "ContentType", "")

  Dim xmlPropsDesc As XmlAttribute = xmlDoc.CreateAttribute("Description")
  xmlPropsDesc.Value = ctDescription
  xmlProps.Attributes.Append(xmlPropsDesc)

  'Create xml node for results.
  Dim xmlResult As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Result", "")

  Try
    'Update the list content type.
    xmlResult.InnerXml = listService.UpdateContentType(listName, contentTypeId, xmlProps, xmlFields, xmlFields, xmlFields, "true").OuterXml.ToString

    'Display the results.
      MessageBox.Show(xmlResult.InnerXml.ToString)

  Catch ex As SoapException
    MessageBox.Show("Message:" + ControlChars.Lf + ex.Message & _
      ControlChars.Lf & _
    "Detail:" + ControlChars.Lf + ex.Detail.InnerText & _
      ControlChars.Lf & _
    "StackTrace:" & ControlChars.Lf + ex.StackTrace)

  Catch ex As Exception
    MessageBox.Show(ex.Message.ToString)

  End Try

End Sub

Community Additions

ADD
Show:
© 2015 Microsoft