Class FieldAndContentTypeExtensions
This class provides extension methods that will help you work with fields and content types.
Inheritance
Namespace: Microsoft.SharePoint.Client
Assembly: PnP.Framework.dll
Syntax
public static class FieldAndContentTypeExtensions : object
Methods
AddContentTypeToList(List, ContentType, Boolean)
Add content type to list
Declaration
public static bool AddContentTypeToList(this List list, ContentType contentType, bool defaultContent = false)
Parameters
List
list
List to add content type to |
Content Content type to add to the list |
System. If set true, content type is updated to be default content type for the list |
Returns
System.
|
AddContentTypeToList(Web, String, ContentType, Boolean)
Adds content type to list
Declaration
public static void AddContentTypeToList(this Web web, string listTitle, ContentType contentType, bool defaultContent = false)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Title of the list |
Content Content type to be added to the list |
System. If set true, content type is updated to be default content type for the list |
AddContentTypeToListById(List, String, Boolean, Boolean)
Add content type to list
Declaration
public static bool AddContentTypeToListById(this List list, string contentTypeID, bool defaultContent = false, bool searchContentTypeInSiteHierarchy = false)
Parameters
List
list
List to add content type to |
System. Complete ID for the content type |
System. If set true, content type is updated to be default content type for the list |
System. search for content type in site hierarchy |
Returns
System.
|
AddContentTypeToListById(Web, String, String, Boolean, Boolean)
Adds content type to list
Declaration
public static void AddContentTypeToListById(this Web web, string listTitle, string contentTypeId, bool defaultContent = false, bool searchContentTypeInSiteHierarchy = false)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Title of the list |
System. Complete ID for the content type |
System. Optionally make this the default content type |
System. search for content type in site hierarchy |
AddContentTypeToListByName(List, String, Boolean, Boolean)
Add content type to list
Declaration
public static bool AddContentTypeToListByName(this List list, string contentTypeName, bool defaultContent = false, bool searchContentTypeInSiteHierarchy = false)
Parameters
List
list
List to add content type to |
System. Name of the content type |
System. If set true, content type is updated to be default content type for the list |
System. search for content type in site hierarchy |
Returns
System.
|
AddContentTypeToListByName(Web, String, String, Boolean, Boolean)
Adds content type to list
Declaration
public static void AddContentTypeToListByName(this Web web, string listTitle, string contentTypeName, bool defaultContent = false, bool searchContentTypeInSiteHierarchy = false)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Title of the list |
System. Name of the content type |
System. Optionally make this the default content type |
System. search for content type in site hierarchy |
AddFieldById(ContentType, Guid, Boolean, Boolean, Boolean, Boolean, Boolean)
Associates field to content type
Declaration
public static void AddFieldById(this ContentType contentType, Guid fieldId, bool required = false, bool hidden = false, bool updateChildren = true, bool showInDisplayForm = true, bool readOnly = false)
Parameters
Content Content Type to add the field to |
Guid
fieldId
The Id of the field |
System. True if the field is required |
System. True if the field is hidden |
System. True to update content types that inherit from the content type; otherwise, false. |
System. Optionally show this field in the display form. |
System. Optionally make this a read only field. |
AddFieldById(ContentType, String, Boolean, Boolean, Boolean, Boolean, Boolean)
Associates field to content type
Declaration
public static void AddFieldById(this ContentType contentType, string fieldId, bool required = false, bool hidden = false, bool updateChildren = true, bool showInDisplayForm = true, bool readOnly = false)
Parameters
Content Content Type to add the field to |
System. String representation of the id of the field (=Guid) |
System. True if the field is required |
System. True if the field is hidden |
System. True to update content types that inherit from the content type; otherwise, false. |
System. Optionally show this field in the display form. |
System. Optionally make this a read only field. |
AddFieldByName(ContentType, String, Boolean, Boolean, Boolean, Boolean, Boolean)
Associates field to content type
Declaration
public static void AddFieldByName(this ContentType contentType, string fieldName, bool required = false, bool hidden = false, bool updateChildren = true, bool showInDisplayForm = true, bool readOnly = false)
Parameters
Content Content Type to add the field to |
System. The title or internal name of the field |
System. True if the field is required |
System. True if the field is hidden |
System. True to update content types that inherit from the content type; otherwise, false. |
System. Optionally show this field in the display form. |
System. Optionally make this a read only field. |
AddFieldToContentType(Web, ContentType, Field, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>)
Associates field to content type
Declaration
public static void AddFieldToContentType(this Web web, ContentType contentType, Field field, bool? required, bool? hidden, bool? updateChildren, bool? showInDisplayForm, bool? readOnly)
Parameters
Web
web
Site to be processed - can be root web or sub site |
Content Content type to associate field to |
Field
field
Field to associate to the content type |
System. Optionally make this a required field |
System. Optionally make this a hidden field |
System. True to update content types that inherit from the content type; otherwise, false. |
System. Optionally show this field in the display form. |
System. Optionally make this a read only field. |
AddFieldToContentTypeById(Web, String, String, Boolean, Boolean, Boolean, Boolean, Boolean)
Associates field to content type
Declaration
public static void AddFieldToContentTypeById(this Web web, string contentTypeID, string fieldId, bool required = false, bool hidden = false, bool updateChildren = true, bool showInDisplayForm = true, bool readOnly = false)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. String representation of the id of the content type to add the field to |
System. String representation of the field ID (=guid) |
System. True if the field is required |
System. True if the field is hidden |
System. True to update content types that inherit from the content type; otherwise, false. |
System. Optionally show this field in the display form. |
System. Optionally make this a read only field. |
AddFieldToContentTypeByName(Web, String, Guid, Boolean, Boolean, Boolean, Boolean, Boolean)
Associates field to content type
Declaration
public static void AddFieldToContentTypeByName(this Web web, string contentTypeName, Guid fieldID, bool required = false, bool hidden = false, bool updateChildren = true, bool showInDisplayForm = true, bool readOnly = false)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Name of the content type |
Guid
fieldID
Guid representation of the field ID |
System. True if the field is required |
System. True if the field is hidden |
System. True to update content types that inherit from the content type; otherwise, false. |
System. Optionally show this field in the display form. |
System. Optionally make this a read only field. |
BestMatch(ContentTypeCollection, ContentTypeId)
Searches for the content type with the closest match to the specified content type ID. If the search finds two matches, the shorter ID is returned.
Declaration
public static ContentTypeId BestMatch(this ContentTypeCollection contentTypes, ContentTypeId contentTypeId)
Parameters
Content Content type collection to search |
Content Content type id for the content type to search |
Returns
Content Content type Id object or null if was not found |
BestMatch(ContentTypeCollection, String)
Searches for the content type with the closest match to the value of the specified content type ID. If the search finds two matches, the shorter ID is returned.
Declaration
public static ContentTypeId BestMatch(this ContentTypeCollection contentTypes, string contentTypeId)
Parameters
Content Content type collection to search |
System. Complete ID for the content type to search |
Returns
Content Content type Id object or null if was not found |
BestMatch(ContentTypeId, IEnumerable<ContentType>)
Searches for the content type with the closest match to this content type id. If the search finds two matches, the shorter ID is returned.
Declaration
public static ContentTypeId BestMatch(ContentTypeId contentTypeId, IEnumerable<ContentType> contentTypeCollection)
Parameters
Content Content type id for the content type to search |
IEnumerable<Content Content type collection to search |
Returns
Content Content type Id object or null if was not found |
BestMatchContentTypeId(List, String)
Searches the list content types and returns the content type identifier (ID) that is the nearest match to the specified content type ID.
Declaration
public static ContentTypeId BestMatchContentTypeId(this List list, string baseContentTypeId)
Parameters
List
list
The list to check for content types |
System. A string with the base content type ID to match. |
Returns
Content The value of the Id property for the content type with the closest match to the value of the specified content type ID. |
Remarks
If the search finds multiple matches, the shorter ID is returned. For example, if 0x0101 is the argument, and the collection contains both 0x010109 and 0x01010901, the method returns 0x010109.
ContentTypeExistsById(List, String)
Does content type exist in list
Declaration
public static bool ContentTypeExistsById(this List list, string contentTypeId)
Parameters
List
list
List to update |
System. Complete ID for the content type |
Returns
System. True if the content type exists, false otherwise |
ContentTypeExistsById(Web, String, Boolean)
Does content type exists in the web
Declaration
public static bool ContentTypeExistsById(this Web web, string contentTypeId, bool searchInSiteHierarchy = false)
Parameters
Web
web
Web to be processed |
System. Complete ID for the content type |
System. Searches accross all content types in the site up to the root site |
Returns
System. True if the content type exists, false otherwise |
ContentTypeExistsById(Web, String, String)
Does content type exist in web
Declaration
public static bool ContentTypeExistsById(this Web web, string listTitle, string contentTypeId)
Parameters
Web
web
Web to be processed |
System. Title of the list to be updated |
System. Complete ID for the content type |
Returns
System. True if the content type exists, false otherwise |
ContentTypeExistsByName(List, String)
Does content type exist in list
Declaration
public static bool ContentTypeExistsByName(this List list, string contentTypeName)
Parameters
List
list
List to update |
System. Name of the content type |
Returns
System. True if the content type exists, false otherwise |
ContentTypeExistsByName(Web, String, Boolean)
Does content type exists in the web
Declaration
public static bool ContentTypeExistsByName(this Web web, string contentTypeName, bool searchInSiteHierarchy = false)
Parameters
Web
web
Web to be processed |
System. Name of the content type |
System. Searches accross all content types in the site up to the root site |
Returns
System. True if the content type exists, false otherwise |
ContentTypeExistsByName(Web, String, String)
Does content type exist in web
Declaration
public static bool ContentTypeExistsByName(this Web web, string listTitle, string contentTypeName)
Parameters
Web
web
Web to be processed |
System. Title of the list to be updated |
System. Name of the content type |
Returns
System. True if the content type exists, false otherwise |
CreateContentType(Web, String, String, String)
Create new content type to web
Declaration
public static ContentType CreateContentType(this Web web, string name, string id, string group)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Name of the content type |
System. Complete ID for the content type |
System. Group for the content type |
Returns
Content Returns newly created content type |
CreateContentType(Web, String, String, String, String, ContentType)
Create new content type to web
Declaration
public static ContentType CreateContentType(this Web web, string name, string description, string id, string group, ContentType parentContentType = null)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Name of the content type |
System. Description for the content type |
System. Complete ID for the content type |
System. Group for the content type |
Content Parent Content Type |
Returns
Content The created content type |
CreateContentTypeFromXML(Web, XDocument)
Create a content type based on the classic feature framework structure.
Declaration
public static ContentType CreateContentTypeFromXML(this Web web, XDocument xDocument)
Parameters
Web
web
Web to operate against |
XDocument
xDocument
Actual XML document |
Returns
Content
|
CreateContentTypeFromXMLFile(Web, String)
Create a content type based on the classic feature framework structure.
Declaration
public static ContentType CreateContentTypeFromXMLFile(this Web web, string absolutePathToFile)
Parameters
Web
web
Web to operate against |
System. Absolute path to the xml location |
Returns
Content
|
CreateContentTypeFromXMLString(Web, String)
Create a content type based on the classic feature framework structure.
Declaration
public static ContentType CreateContentTypeFromXMLString(this Web web, string xmlStructure)
Parameters
Web
web
Web to operate against |
System. XML structure in string format |
Returns
Content
|
CreateField(List, FieldCreationInformation, Boolean)
Adds field to a list
Declaration
public static Field CreateField(this List list, FieldCreationInformation fieldCreationInformation, bool executeQuery = true)
Parameters
List
list
List to process |
Field Creation information for the field |
System. Optionally skip the executeQuery action |
Returns
Field
The newly created field or existing field. |
CreateField(List, String, Boolean)
Adds a field to a list
Declaration
public static Field CreateField(this List list, string fieldAsXml, bool executeQuery = true)
Parameters
List
list
List to process |
System. The XML declaration of SiteColumn definition |
System. Optionally skip the executeQuery action |
Returns
Field
The newly created field or existing field. |
CreateField(Web, FieldCreationInformation, Boolean)
Create field to web remotely
Declaration
public static Field CreateField(this Web web, FieldCreationInformation fieldCreationInformation, bool executeQuery = true)
Parameters
Web
web
Site to be processed - can be root web or sub site |
Field Creation Information for the field. |
System. Optionally skip the executeQuery action |
Returns
Field
The newly created field or existing field. |
CreateField(Web, String, Boolean)
Create field to web remotely
Declaration
public static Field CreateField(this Web web, string fieldAsXml, bool executeQuery = true)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. The XML declaration of SiteColumn definition |
System. Executes query if true |
Returns
Field
The newly created field or existing field. |
CreateField<TField>(List, FieldCreationInformation, Boolean)
Adds field to a list
Declaration
public static TField CreateField<TField>(this List list, FieldCreationInformation fieldCreationInformation, bool executeQuery = true)
where TField : Field
Parameters
List
list
List to process |
Field Field creation information |
System. Optionally skip the executeQuery action |
Returns
TField
The newly created field or existing field. |
Type Parameters
TField
The selected field type to return. |
CreateField<TField>(Web, FieldCreationInformation, Boolean)
Create field to web remotely
Declaration
public static TField CreateField<TField>(this Web web, FieldCreationInformation fieldCreationInformation, bool executeQuery = true)
where TField : Field
Parameters
Web
web
Site to be processed - can be root web or sub site |
Field Field creation information |
System. Optionally skip the executeQuery action |
Returns
TField
The newly created field or existing field. |
Type Parameters
TField
The created field type to return. |
CreateFieldsFromXML(Web, XDocument)
Creates field from xml structure which follows the classic feature framework structure
Declaration
public static void CreateFieldsFromXML(this Web web, XDocument xDocument)
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
XDocument
xDocument
Actual XML document |
CreateFieldsFromXMLFile(Web, String)
Creates fields from feature element xml file schema. XML file can contain one or many field definitions created using classic feature framework structure.
Declaration
public static void CreateFieldsFromXMLFile(this Web web, string xmlFilePath)
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
System. Absolute path to the xml location |
CreateFieldsFromXMLString(Web, String)
Creates fields from feature element xml file schema. XML file can contain one or many field definitions created using classic feature framework structure.
Declaration
public static void CreateFieldsFromXMLString(this Web web, string xmlStructure)
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
System. XML structure in string format |
DeleteContentTypeById(Web, String)
Deletes a content type from the web by id
Declaration
public static void DeleteContentTypeById(this Web web, string contentTypeId)
Parameters
Web
web
Web to delete the content type from |
System. Id of the content type to delete |
DeleteContentTypeByName(Web, String)
Deletes a content type from the web by name
Declaration
public static void DeleteContentTypeByName(this Web web, string contentTypeName)
Parameters
Web
web
Web to delete the content type from |
System. Name of the content type to delete |
FieldExistsById(List, Guid)
Returns if the field is found
Declaration
public static bool FieldExistsById(this List list, Guid fieldId)
Parameters
List
list
List to process |
Guid
fieldId
Guid of the field ID |
Returns
System. True if the fields exists, false otherwise |
FieldExistsById(List, String)
Returns if the field is found, query based on the ID
Declaration
public static bool FieldExistsById(this List list, string fieldId)
Parameters
List
list
List to process |
System. String representation of the field ID (=guid) |
Returns
System. True if the fields exists, false otherwise |
FieldExistsById(Web, Guid, Boolean)
Returns if the field is found
Declaration
public static bool FieldExistsById(this Web web, Guid fieldId, bool searchInSiteHierarchy = false)
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
Guid
fieldId
Guid for the field ID |
System. If true, search parent sites and root site |
Returns
System. True or false depending on the field existence |
FieldExistsById(Web, String, Boolean)
Does field exist in web
Declaration
public static bool FieldExistsById(this Web web, string fieldId, bool searchInSiteHierarchy = false)
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
System. String representation of the field ID (=guid) |
System. If true, search parent sites and root site |
Returns
System. True if exists, false otherwise |
FieldExistsByName(List, String)
Field exists in list by name
Declaration
public static bool FieldExistsByName(this List list, string fieldName)
Parameters
List
list
List to process |
System. Internal name of the field |
Returns
System. True if the fields exists, false otherwise |
FieldExistsByName(Web, String, Boolean)
Returns if the field is found
Declaration
public static bool FieldExistsByName(this Web web, string fieldName, bool searchInSiteHierarchy = false)
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
System. String for the field internal name to be used as query criteria |
System. If true, search parent sites and root site |
Returns
System. True or false depending on the field existence |
FieldExistsByNameInContentType(ContentType, String)
Checks if a field exists in a content type by id
Declaration
public static bool FieldExistsByNameInContentType(this ContentType contentType, string fieldName)
Parameters
Content The content type to check |
System. The name of the field to look for |
Returns
System. True if field exists in content type, otherwise false |
FieldExistsByNameInContentType(Web, String, String)
Field exists in content type
Declaration
public static bool FieldExistsByNameInContentType(this Web web, string contentTypeName, string fieldName)
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
System. Name of the content type |
System. Name of the field |
Returns
System. True if exists, false otherwise |
FormatFieldXml(FieldCreationInformation)
Formats a fieldcreationinformation object into Field CAML xml.
Declaration
public static string FormatFieldXml(FieldCreationInformation fieldCreationInformation)
Parameters
Field Field Cration Information object |
Returns
System.
|
GetAllowDeletion(Field)
Gets the AllowDeletion property from a field.
Note 1: This method will load field
.SchemaXmlWithResourceTokens if not any of the properties field
.SchemaXmlWithResourceTokens or field
.SchemaXml is already loaded by the caller.
Declaration
public static bool? GetAllowDeletion(this Field field)
Parameters
Field
field
Field to be processed |
Returns
System. Returns false if field deletion is not allowed, true if field deletion is allowed, and null if the field default behavior is used to determine if field deletion is allowed. |
GetContentTypeById(List, String)
Return content type by Id
Declaration
public static ContentType GetContentTypeById(this List list, string contentTypeId)
Parameters
List
list
List to update |
System. Complete ID for the content type |
Returns
Content Content type object or null if was not found |
GetContentTypeById(Web, String, Expression<Func<ContentTypeCollection, Object>>, Boolean)
Return content type by Id
Declaration
public static ContentType GetContentTypeById(this Web web, string contentTypeId, Expression<Func<ContentTypeCollection, object>> retrievals, bool searchInSiteHierarchy = false)
Parameters
Web
web
Web to be processed |
System. Complete ID for the content type |
Expression<Func<Content Specify additional data to load when retrieving the content types |
System. Searches accross all content types in the site up to the root site |
Returns
Content Content type object or null if was not found |
GetContentTypeById(Web, String, Boolean)
Return content type by Id
Declaration
public static ContentType GetContentTypeById(this Web web, string contentTypeId, bool searchInSiteHierarchy = false)
Parameters
Web
web
Web to be processed |
System. Complete ID for the content type |
System. Searches accross all content types in the site up to the root site |
Returns
Content Content type object or null if was not found |
GetContentTypeByName(List, String)
Return content type by name
Declaration
public static ContentType GetContentTypeByName(this List list, string contentTypeName)
Parameters
List
list
List to update |
System. Name of the content type |
Returns
Content Content type object or null if was not found |
GetContentTypeByName(Web, String, Boolean)
Return content type by name
Declaration
public static ContentType GetContentTypeByName(this Web web, string contentTypeName, bool searchInSiteHierarchy = false)
Parameters
Web
web
Web to be processed |
System. Name of the content type |
System. Searches accross all content types in the site up to the root site |
Returns
Content Content type object or null if was not found |
GetDefaultColumnValueFromField(Field, ClientContext, String, String[])
Declaration
public static IDefaultColumnValue GetDefaultColumnValueFromField(this Field field, ClientContext clientContext, string folderRelativePath, string[] value)
Parameters
Field
field
|
Client
|
System.
|
System.
|
Returns
GetFieldById(List, Guid)
Returns the field if it exists. Null if it does not exist.
Declaration
public static Field GetFieldById(this List list, Guid fieldId)
Parameters
List
list
List to be processed. Columns assoc in lists are defined on web or rootweb. |
Guid
fieldId
Guid for the field ID |
Returns
Field
Field |
GetFieldById(Web, Guid, Boolean)
Returns the field if it exists. Null if it does not exist.
Declaration
public static Field GetFieldById(this Web web, Guid fieldId, bool searchInSiteHierarchy = false)
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
Guid
fieldId
Guid for the field ID |
System. If true, search parent sites and root site |
Returns
Field
Field of type TField |
GetFieldById<TField>(List, Guid)
Returns the field if it exists. Null if it does not exist.
Declaration
public static TField GetFieldById<TField>(this List list, Guid fieldId)
where TField : Field
Parameters
List
list
List to be processed. Columns assoc in lists are defined on web or rootweb. |
Guid
fieldId
Guid for the field ID |
Returns
TField
Field of type TField |
Type Parameters
TField
The selected field type to return. |
GetFieldById<TField>(Web, Guid, Boolean)
Returns the field if it exists. Null if it does not exist.
Declaration
public static TField GetFieldById<TField>(this Web web, Guid fieldId, bool searchInSiteHierarchy = false)
where TField : Field
Parameters
Web
web
Site to be processed - can be root web or sub site. Site columns should be created to root site. |
Guid
fieldId
Guid for the field ID |
System. If true, search parent sites and root site |
Returns
TField
Field of type TField |
Type Parameters
TField
The selected field type to return. |
GetFieldByInternalName(FieldCollection, String)
Returns the field if it exists. Null if it does not exist.
Declaration
public static Field GetFieldByInternalName(this FieldCollection fields, string internalName)
Parameters
Field FieldCollection to be processed. |
System. Internal name of the field |
Returns
Field
Field |
GetFieldByInternalName(Web, String, Boolean)
Returns the field if it exists. Null if does not exist.
Declaration
public static Field GetFieldByInternalName(this Web web, string internalName, bool searchInSiteHierarchy = false)
Parameters
Web
web
Web to be processed |
System. If true, search parent sites and root site |
System. If true, search across all the available fields in the site hierarchy |
Returns
Field
Field |
GetFieldByInternalName<TField>(FieldCollection, String)
Returns the field if it exists. Null if it does not exist.
Declaration
public static TField GetFieldByInternalName<TField>(this FieldCollection fields, string internalName)
where TField : Field
Parameters
Field FieldCollection to be processed. |
System. Internal name of the field |
Returns
TField
Field of type TField |
Type Parameters
TField
The selected field type to return. |
GetFieldByName(FieldCollection, String)
Returns the field if it exists. Null if it does not exist.
Declaration
public static Field GetFieldByName(this FieldCollection fields, string internalName)
Parameters
Field FieldCollection to be processed. |
System. Guid for the field ID |
Returns
Field
Field |
GetFieldByName<TField>(FieldCollection, String)
Returns the field if it exists. Null if it does not exist.
Declaration
public static TField GetFieldByName<TField>(this FieldCollection fields, string internalName)
where TField : Field
Parameters
Field FieldCollection to be processed. |
System. Guid for the field ID |
Returns
TField
Field of type TField |
Type Parameters
TField
The selected field type to return. |
GetFields(List, String[])
Gets a list of fields from a list by names.
Declaration
public static IEnumerable<Field> GetFields(this List list, params string[] fieldInternalNames)
Parameters
List
list
The target list containing the fields. |
System. List of field names to retreieve. |
Returns
IEnumerable<Field>
List of fields requested. |
GetIsAllowedInContentTypeOrder(ContentType)
Checks if the content type is allowed to be set in the content type order.
Declaration
public static bool GetIsAllowedInContentTypeOrder(this ContentType contentType)
Parameters
Content Target content type to check |
Returns
System.
|
GetParentIdValue(ContentTypeId)
Calculates the parent content type id
Declaration
public static string GetParentIdValue(this ContentTypeId contentTypeId)
Parameters
Content Content type id to calculate the parent content type id from |
Returns
System.
|
HideContentTypesInNewButton(List, IList<ContentType>)
Hides the specified content types in the list new button. Existing visibility and content type order is not altered.
Declaration
public static void HideContentTypesInNewButton(this List list, IList<ContentType> contentTypes)
Parameters
List
list
Target list containing the content types |
IList<Content Content types to hide |
Remarks
Content types specified in contentTypes
needs to be the actual content type in the list and not it's parent.
IsChildOf(ContentTypeId, ContentTypeId)
Calculates if a content type id is a child of another content type id
Declaration
public static bool IsChildOf(this ContentTypeId current, ContentTypeId contentTypeId)
Parameters
Content Parent content type id |
Content Content type id to check |
Returns
System.
|
IsParentOf(ContentTypeId, ContentTypeId)
Calculates if a content type id is a parent of another content type id
Declaration
public static bool IsParentOf(this ContentTypeId current, ContentTypeId contentTypeId)
Parameters
Content Child content type id |
Content Content type id to check |
Returns
System.
|
RemoveContentTypeFromList(Web, List, ContentType)
Removes content type from a list
Declaration
public static void RemoveContentTypeFromList(this Web web, List list, ContentType contentType)
Parameters
Web
web
Site to be processed - can be root web or sub site |
List
list
The List |
Content The Content Type |
RemoveContentTypeFromListById(Web, List, String)
Removes content type from a list
Declaration
public static void RemoveContentTypeFromListById(this Web web, List list, string contentTypeId)
Parameters
Web
web
Site to be processed - can be root web or sub site |
List
list
The List |
System. Complete ID for the content type |
RemoveContentTypeFromListById(Web, String, String)
Removes content type from a list
Declaration
public static void RemoveContentTypeFromListById(this Web web, string listTitle, string contentTypeId)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Title of the list |
System. Complete ID for the content type |
RemoveContentTypeFromListByName(Web, List, String)
Removes content type from list
Declaration
public static void RemoveContentTypeFromListByName(this Web web, List list, string contentTypeName)
Parameters
Web
web
Site to be processed - can be root web or sub site |
List
list
The List |
System. The name of the content type |
RemoveContentTypeFromListByName(Web, String, String)
Removes content type from list
Declaration
public static void RemoveContentTypeFromListByName(this Web web, string listTitle, string contentTypeName)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Title of the list |
System. The name of the content type |
RemoveFieldById(Web, String)
Removes a field by specifying its ID
Declaration
public static void RemoveFieldById(this Web web, string fieldId)
Parameters
Web
web
Web to process |
System. The id of the field to remove |
RemoveFieldByInternalName(Web, String)
Removes a field by specifying its internal name
Declaration
public static void RemoveFieldByInternalName(this Web web, string internalName)
Parameters
Web
web
Web to process |
System. Internal name of the field |
ReorderContentTypes(List, IEnumerable<String>)
Reorders content types on the list. The first one in the list is the default item. Any items left out from the list will still be on the content type, but will not be visible on the new button.
Declaration
public static void ReorderContentTypes(this List list, IEnumerable<string> contentTypeNamesOrIds)
Parameters
List
list
Target list containing the content types |
IEnumerable<System. Content type names or ids to sort. |
SetAllowDeletion(Field, Nullable<Boolean>)
Sets the AllowDeletion property on a field.
Note 1: This method will load field
.SchemaXmlWithResourceTokens if it's not already loaded by the caller.
Note 2: This method does not update the field nor execute the query.
Declaration
public static void SetAllowDeletion(this Field field, bool? AllowDeletion)
Parameters
Field
field
Field to be processed |
System. False blocks field deletion, True enables field deletion. Null uses field default behavior. |
SetDefaultContentType(List, ContentTypeId)
Sets the default content type in a list.
Declaration
public static void SetDefaultContentType(this List list, ContentTypeId contentTypeId)
Parameters
List
list
Target list containing the content type |
Content Id of the list content type to make default. |
Remarks
Content type specified in contentTypeId
needs to be
the id of the actual content type in the list and not it's parent.
SetDefaultContentType(List, String)
Sets the default content type in a list.
Declaration
public static void SetDefaultContentType(this List list, string contentTypeId)
Parameters
List
list
Target list containing the content type |
System. Id of the list content type to make default. |
Remarks
Content type specified in contentTypeId
needs to be
the id of the actual content type in the list and not it's parent.
SetDefaultContentTypeToList(List, ContentType)
Set default content type to list
Declaration
public static void SetDefaultContentTypeToList(this List list, ContentType contentType)
Parameters
List
list
List to update |
Content Content type to make default |
SetDefaultContentTypeToList(List, String)
Set's default content type list.
Declaration
public static void SetDefaultContentTypeToList(this List list, string contentTypeId)
Parameters
List
list
List to update |
System. Complete ID for the content type |
Remarks
Notice. Currently removes other content types from the list. Known issue
SetDefaultContentTypeToList(Web, List, ContentType)
Set default content type to list
Declaration
public static void SetDefaultContentTypeToList(this Web web, List list, ContentType contentType)
Parameters
Web
web
Site to be processed - can be root web or sub site |
List
list
List to update |
Content Content type to make default |
SetDefaultContentTypeToList(Web, List, String)
Set default content type to list
Declaration
public static void SetDefaultContentTypeToList(this Web web, List list, string contentTypeId)
Parameters
Web
web
Site to be processed - can be root web or sub site |
List
list
List to update |
System. Complete ID for the content type |
SetDefaultContentTypeToList(Web, String, ContentType)
Set's default content type list.
Declaration
public static void SetDefaultContentTypeToList(this Web web, string listTitle, ContentType contentType)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Title of the list to be updated |
Content Content type to make default |
SetDefaultContentTypeToList(Web, String, String)
Set default content type to list
Declaration
public static void SetDefaultContentTypeToList(this Web web, string listTitle, string contentTypeId)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Title of the list to be updated |
System. Complete ID for the content type |
SetJsLinkCustomizations(Field, String)
Adds jsLink to a field.
Declaration
public static void SetJsLinkCustomizations(this Field field, string jsLink)
Parameters
Field
field
The field to add jsLink to |
System. JSLink to set to the form. Set to empty string to remove the set JSLink customization. Specify multiple values separated by pipe symbol. For e.g.: ~sitecollection/_catalogs/masterpage/jquery-2.1.0.min.js|~sitecollection/_catalogs/masterpage/custom.js |
SetJsLinkCustomizations(List, String, String)
Adds jsLink to a list field.
Declaration
public static void SetJsLinkCustomizations(this List list, string fieldName, string jsLink)
Parameters
List
list
The list where the field exists. |
System. The field to add jsLink to. |
System. JSLink to set to the form. Set to empty string to remove the set JSLink customization. Specify multiple values separated by pipe symbol. For e.g.: ~sitecollection/_catalogs/masterpage/jquery-2.1.0.min.js|~sitecollection/_catalogs/masterpage/custom.js |
SetLocalizationForContentType(ContentType, String, String, String)
Set localized labels for content type
Declaration
public static void SetLocalizationForContentType(this ContentType contentType, string cultureName, string nameResource, string descriptionResource)
Parameters
Content Name of the content type |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Name property |
System. Localized value for the Description property |
SetLocalizationForContentType(List, String, String, String, String)
Set localized labels for content type
Declaration
public static void SetLocalizationForContentType(this List list, string contentTypeId, string cultureName, string nameResource, string descriptionResource)
Parameters
List
list
List to update |
System. Complete ID for the content type |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Name property |
System. Localized value for the Description property |
SetLocalizationForContentType(Web, String, String, String, String)
Set localized labels for content type
Declaration
public static void SetLocalizationForContentType(this Web web, string contentTypeName, string cultureName, string nameResource, string descriptionResource)
Parameters
Web
web
Web to operate on |
System. Name of the content type |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Name property |
System. Localized value for the Description property |
SetLocalizationForField(Field, String, String, String)
Set localized labels for field
Declaration
public static void SetLocalizationForField(this Field field, string cultureName, string titleResource, string descriptionResource)
Parameters
Field
field
Field to update |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Title property |
System. Localized value for the Description property |
SetLocalizationForField(List, Field, String, String, String)
Set localized labels for field
Declaration
public static void SetLocalizationForField(this List list, Field siteColumn, string cultureName, string titleResource, string descriptionResource)
Parameters
List
list
List to update |
Field
siteColumn
Site column to update |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Title property |
System. Localized value for the Description property |
SetLocalizationForField(List, Guid, String, String, String)
Set localized labels for field
Declaration
public static void SetLocalizationForField(this List list, Guid siteColumnId, string cultureName, string titleResource, string descriptionResource)
Parameters
List
list
List to update |
Guid
siteColumnId
Guid of the site column ID |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Title property |
System. Localized value for the Description property |
SetLocalizationForField(List, String, String, String, String)
Set localized labels for field
Declaration
public static void SetLocalizationForField(this List list, string siteColumnName, string cultureName, string titleResource, string descriptionResource)
Parameters
List
list
List to update |
System. Name of the site column |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Title property |
System. Localized value for the Description property |
SetLocalizationForField(Web, Field, String, String, String)
Set localized labels for field
Declaration
public static void SetLocalizationForField(this Web web, Field siteColumn, string cultureName, string titleResource, string descriptionResource)
Parameters
Web
web
Web to operate on |
Field
siteColumn
Site column to localize |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Title property |
System. Localized value for the Description property |
SetLocalizationForField(Web, Guid, String, String, String)
Set localized labels for field
Declaration
public static void SetLocalizationForField(this Web web, Guid siteColumnId, string cultureName, string titleResource, string descriptionResource)
Parameters
Web
web
Web to operate on |
Guid
siteColumnId
Guid with the site column ID |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Title property |
System. Localized value for the Description property |
SetLocalizationForField(Web, String, String, String, String)
Set localized labels for field
Declaration
public static void SetLocalizationForField(this Web web, string siteColumnName, string cultureName, string titleResource, string descriptionResource)
Parameters
Web
web
Web to operate on |
System. Name of the site column |
System. Culture for the localization (en-es, nl-be, fi-fi,...) |
System. Localized value for the Title property |
System. Localized value for the Description property |
ShowContentTypesInNewButton(List, IList<ContentType>)
Makes the specified content types visible in the list new button. Existing visibility and content type order is not altered.
Declaration
public static void ShowContentTypesInNewButton(this List list, IList<ContentType> contentTypes)
Parameters
List
list
Target list containing the content types |
IList<Content List content types to make visible |
Remarks
Content types specified in contentTypes
needs to be the actual content type in the list and not it's parent.
UpdateContentTypeById(Web, String, String, String, String, String, String, String, String, Nullable<Boolean>)
Update existing content type of a web
Declaration
public static ContentType UpdateContentTypeById(this Web web, string Id, string newContentTypeName = "", string description = "", string group = "", string displayFormUrl = "", string newFormUrl = "", string editFormUrl = "", string documentTemplate = "", bool? hidden = null)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Id of the content type |
System. Updated name of the content type |
System. Description for the content type |
System. Group for the content type |
System. Display form url of the content type |
System. New form url of the content type |
System. Edit form url of the content type |
System. Document template of the content type |
System. Toggle value indicating whether content type should be hidden or not |
Returns
Content The updated content type |
UpdateContentTypeByName(Web, String, String, String, String, String, String, String, String, Nullable<Boolean>)
Update existing content type of a web
Declaration
public static ContentType UpdateContentTypeByName(this Web web, string name, string newContentTypeName = "", string description = "", string group = "", string displayFormUrl = "", string newFormUrl = "", string editFormUrl = "", string documentTemplate = "", bool? hidden = null)
Parameters
Web
web
Site to be processed - can be root web or sub site |
System. Name of the content type |
System. Updated name of the content type |
System. Description for the content type |
System. Group for the content type |
System. Display form url of the content type |
System. New form url of the content type |
System. Edit form url of the content type |
System. Document template of the content type |
System. Toggle value indicating whether content type should be hidden or not |
Returns
Content The updated content type |