FieldLookup.RelationshipDeleteBehavior property
Gets or sets a value that specifies the delete behavior of the lookup field.
Namespace: Microsoft.SharePoint.Client
Assembly: Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
Syntax
'Declaration
Public Property RelationshipDeleteBehavior As RelationshipDeleteBehaviorType
Get
Set
'Usage
Dim instance As FieldLookup
Dim value As RelationshipDeleteBehaviorType
value = instance.RelationshipDeleteBehavior
instance.RelationshipDeleteBehavior = value
public RelationshipDeleteBehaviorType RelationshipDeleteBehavior { get; set; }
Property value
Type: Microsoft.SharePoint.Client.RelationshipDeleteBehaviorType
Returns a RelationshipDeleteBehaviorType instance representing the delete behavior of the lookup field.
Exceptions
Exception | Condition |
---|---|
[Microsoft.SharePoint.SPException] | The server does not allow properties of the field to be changed. Error code: -2146232832. |
[System.NotSupportedException] | The list that the field belongs to is an external list. Error code: -1. |
Remarks
The RelationshipDeleteBehavior property enables you enforce referential integrity in the relationship between two lists when one list depends on another list. If a lookup field in the dependent list has the RelationshipDeleteBehavior property set to Cascade, then deleting an item from the source list causes all related dependent list items to be deleted as well. For example, suppose you have a Customers list that is related to an Addresses list by a lookup field in the Addresses list. You might want deleting an item from Customers to cause all related items from Addresses to be deleted as well. You could accomplish that by setting the RelationshipDeleteBehavior property of the lookup field in the Addresses list to Cascade.
Setting the RelationshipDeleteBehavior property to Restrict prevents an item in the source list from being deleted if any items in the dependent list look up to it. For example, suppose your Customers list is the source for a lookup field in the Pending Orders list. You might not want an item from the Customers list to be deleted if the customer has pending orders. In that case, you could set the RelationshipDeleteBehavior property for the lookup field in Pending Orders to Restrict.
A lookup field that enforces a deletion constraint must be indexed. Before setting the RelationshipDeleteBehavior property to Cascade or Restrict, first set the Indexed() property to true.
Important
The user must have ManageLists permission on the source list in order to specify either Cascade or Restrict. For more information, see the BasePermissions enumeration.
In addition, you cannot specify a deletion constraint if:
-
The lookup field allows multiple values.
Before setting the RelationshipDeleteBehavior property, be sure that the AllowMultipleValues property returns false.
-
The lookup field points to a list in another Web site.
Check the value of the lookup field's LookupWebId property.
-
The number of items in the list exceeds the maximum set for large lists.
Compare the value returned by the list's ItemCount property with the value returned by the Web application's MaxItemsPerThrottledOperation property.
The current user must have BasePermissions.ManageLists permission on the target list when this property is set to Restrict.