Export (0) Print
Expand All

Lists.UpdateContentType method

Updates the specified list content type.

Namespace:  WebSvcLists
Assembly:  STSSOAP (in STSSOAP.dll)

'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)> _
PublicFunctionUpdateContentType ( _
	listNameAsString, _
	contentTypeIdAsString, _
	contentTypePropertiesAsXmlNode, _
	newFieldsAsXmlNode, _
	updateFieldsAsXmlNode, _
	deleteFieldsAsXmlNode, _
	addToViewAsString _
) AsXmlNode
'Usage
DiminstanceAsListsDimlistNameAsStringDimcontentTypeIdAsStringDimcontentTypePropertiesAsXmlNodeDimnewFieldsAsXmlNodeDimupdateFieldsAsXmlNodeDimdeleteFieldsAsXmlNodeDimaddToViewAsStringDimreturnValueAsXmlNodereturnValue = instance.UpdateContentType(listName, _
	contentTypeId, contentTypeProperties, _
	newFields, updateFields, deleteFields, _
	addToView)

Parameters

listName
Type: System.String

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

contentTypeId
Type: System.String

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

contentTypeProperties
Type: System.Xml.XmlNode

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

newFields
Type: System.Xml.XmlNode

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

updateFields
Type: System.Xml.XmlNode

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

deleteFields
Type: System.Xml.XmlNode

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

addToView
Type: System.String

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.

Return value

Type: System.Xml.XmlNode

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:
© 2014 Microsoft