Error: This constraint cannot be enabled as not all values have corresponding parent values when you try to access Pages & templates in BBIS

Adding a child folder in the CMS, to a folder that has just been deleted will still allow the folder to be created – however will result in errors wherever the folders are used, e.g. on the Site Explorer Pages & Templates section, or on a page’s properties window.

User may see the following error when they try to access 'Site explorer' > 'Pages & templates' in BBIS.
Error:
Server Error in '/' Application.
________________________________________
This constraint cannot be enabled as not all values have corresponding parent values.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: This constraint cannot be enabled as not all values have corresponding parent values.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: This constraint cannot be enabled as not all values have corresponding parent values.]
   System.Data.ConstraintCollection.AddForeignKeyConstraint(ForeignKeyConstraint constraint) +2671615
   System.Data.ConstraintCollection.Add(Constraint constraint, Boolean addUniqueWhenAddingForeign) +553
   System.Data.DataSetRelationCollection.AddCore(DataRelation relation) +1146
   System.Data.DataRelationCollection.Add(DataRelation relation) +185
   System.Data.DataRelationCollection.Add(String name, DataColumn parentColumn, DataColumn childColumn, Boolean createConstraints) +83
   Blackbaud.Web.Content.Core.SiteFolder.GetFoldersDataSet(Int32 ClientSitesID, EFolderType Type) +302
   Blackbaud.Web.Content.Portal.Platform.Folders.FolderTree.BindTree() +74
   Blackbaud.Web.Content.Portal.Platform.Folders.FolderTree.DataBind() +84
   Blackbaud.Web.Content.Portal.Platform.Folders.FolderManager.DataBind() +38
   Blackbaud.Web.Content.Portal.Platform.Galleries.AdminGalleryBase.DataBind() +250
   Blackbaud.Web.Content.Portal.Platform.Galleries.AdminGalleryBase.Page_Load(Object sender, EventArgs e) +48
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnLoad(EventArgs e) +109
   System.Web.UI.Control.LoadRecursive() +68
   System.Web.UI.Control.LoadRecursive() +165
   System.Web.UI.Control.LoadRecursive() +165
   System.Web.UI.Control.LoadRecursive() +165
   System.Web.UI.Control.LoadRecursive() +165
   System.Web.UI.Control.LoadRecursive() +165
   System.Web.UI.Control.LoadRecursive() +165
   System.Web.UI.Control.LoadRecursive() +165
   System.Web.UI.Control.LoadRecursive() +165
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4498
There are two approaches to resolving this, depending on the desired outcome.
 
  1. Mark the child (Folder B) as deleted, where a parent has been deleted: 
UPDATE c
SET c.Deleted = 1
FROM dbo.SiteFolders p, dbo.siteFolders c
WHERE c.ParentFolderID = p.FolderID
       AND c.Deleted = 0
       AND p.Deleted = 1
 
  1. Unmark the parent (Folder A) as deleted, where there is an undeleted child folder:
 
UPDATE p
SET p.Deleted = 0
FROM dbo.SiteFolders p, dbo.siteFolders c
WHERE c.ParentFolderID = p.FolderID
       AND c.Deleted = 0
       AND p.Deleted = 1
 
 

Steps to Duplicate

  1. Create a new folder called Folder A in Site Explorer > Pages & Templates
  2. Open a new window and bring up Pages & Templates
  3. In the second window, add a new folder, Folder B, and select Folder A as the parent – but do not click ‘Save’ yet…
  4. yy
  5. Now back in the first window, delete Folder A
  6. In the second window, click Save on the new folder dialogue
  7. Now accessing Pages & Templates will result in an error.

Environment

 Blackbaud CRM

Was this article helpful?