How to provision a lookup column with enforce delete behavior as "Cascade" ?
What type of issue is this?
Question
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Target SharePoint environment
SharePoint Online
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [x] 💥 Microsoft Edge
- [x] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
- SharePoint Framework version 1.19.0
Issue description
When I tried to re-use an existing lookup Site column in list schema and set RelationshipDeleteBehavior as "Cascade" it doesn't follow that settings. The list is created together with the lookup column but the setting "Enforce relationship behavior" of that lookup column is still unchecked (and the value is also not "Cascade")
If I create a completely new lookup column inside the list scope then the value is set to "Cascade" but there is a new uncheck setting name "Enable relationships for this column" which prevents the "Enforce relationship behavior" to be checked.
Further investigation revealed that the "IsRelationship" value of the Field schema is what controls this "Enable relationships for this column" value. But this is automatically set to true when created as Site column, and default to false when created as List column.
What's more interesting is that the provisioning engine seems to ignore this "IsRelationship" value when it is set inside list column.
So does someone know if the current SPO supports provisioning lookup column with RelationshipDeleteBehavior as "Cascade" ?
Hello @OverkillTV, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.
@OverkillTV , Kindly follow https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ff623048(v=office.14) doc to resolve. Also please give steps to repro the issue
That doc is used for SharePoint on-premise not to mention it was trying to set the Enforce relationship behavior using programmatically way, while I want to set it through schema provisioning.
The steps I used are described in this article: https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/provision-sp-assets-from-package
Except that below is my list schema & elements file: Elements file:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Lookup Columns -->
<Field
ID="{74a7180e-e13a-4987-a178-85a0df8cbc66}"
Name="TestlookupDel"
DisplayName="Lookup Test"
Type="Lookup"
List="Lists/TestListXYZ"
ShowField="Title"
Required="FALSE"
Indexed="TRUE"
Mult="FALSE"
IsRelationship="TRUE"
RelationshipDeleteBehavior="Cascade"
Group="Custom Column">
</Field>
<ListInstance
CustomSchema="schema_TestList.xml"
FeatureId="00bfea71-de22-43b2-a848-c05709900100"
Title="Test List ABC"
Description="List to test"
TemplateType="100"
Hidden="FALSE"
OnQuickLaunch="FALSE"
Url="Lists/TestListABC">
</ListInstance>
<ListInstance
FeatureId="00bfea71-de22-43b2-a848-c05709900100"
Title="Test List XYZ"
Description="List to test"
TemplateType="100"
Hidden="FALSE"
OnQuickLaunch="FALSE"
Url="Lists/TestListXYZ">
</ListInstance>
</Elements>
List schema:
<List xmlns:ows="Microsoft SharePoint" DisableAttachments="TRUE" EnableContentTypes="TRUE" FolderCreation="FALSE" VersioningEnabled="FALSE" BaseType="0" Direction="$Resources:Direction;" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes></ContentTypes>
<Fields>
<Field Name="LinkTitle" DisplayName="Name" Type="Text" />
<Field Name="Title" DisplayName="Name" Type="Text" Indexed="TRUE" />
<Field
ID="{74a7180e-e13a-4987-a178-85a0df8cbc66}"
Name="TestlookupDel"
DisplayName="Lookup Test"
Type="Lookup"
List="Lists/TestListXYZ"
ShowField="Title"
Required="FALSE"
Indexed="TRUE"
Mult="FALSE"
IsRelationship="TRUE"
RelationshipDeleteBehavior="Cascade">
</Field>
<Field
ID="{aafb9a5e-6276-4d5d-bd8b-d3b7fb6dbfd5}"
Name="LookupColumnListScope"
DisplayName="Lookup in List"
Type="Lookup"
List="Lists/TestListXYZ"
ShowField="Title"
Required="FALSE"
Indexed="TRUE"
Mult="FALSE"
IsRelationship="TRUE"
RelationshipDeleteBehavior="Cascade"
/>
</Fields>
<Views>
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
<XslLink Default="TRUE">main.xsl</XslLink>
<JSLink>clienttemplates.js</JSLink>
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard" />
<ViewFields>
<FieldRef Name="LinkTitle"></FieldRef>
<FieldRef Name="TestlookupDel"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="Id" Ascending='False'/>
</OrderBy>
</Query>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
@OverkillTV, We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it. Thanks!
Any news on when this bug will be fixed @Ashlesha-MSFT ? Or is it in any plan in the future ? Right now it's a hassle when trying to provisioning cascade lookup column since there are some extra steps to do to set the cascade settings
@OverkillTV , Thanks for your patience while we investigated this.
Engineering confirmed that this behavior is due to limitations in the legacy Feature Framework provisioning engine. Relationship settings such as IsRelationship and RelationshipDeleteBehavior="Cascade" aren’t reliably applied when provisioning lookup fields through XML schema in SharePoint Online.
Because this area is legacy, a product fix is unlikely at this time. The recommended approach is to set or adjust the relationship settings programmatically after provisioning (e.g., using CSOM/REST/PNP).
We’ve shared the feedback internally, but there is no ETA for a fix.