错误执行引用完整性,因为关系:“包含一个或多个不存在目标列表中一个或多个不存在的项目的值”
-
16-10-2019 - |
题
当我尝试执行这样的参考完整性时:
fieldLookup.Indexed = true;
fieldLookup.RelationshipDeleteBehavior = SPRelationshipDeleteBehavior.Restrict
fieldLookup.Update()
它适用于我应用程序中的大多数,但并非所有字段。失败时,看起来像这样:
Microsoft.SharePoint.SPException: This lookup column cannot enforce a relationship behavior because it contains values that reference one ore more non-existent items in the target list. ---> System.Runtime.InteropServices.COMException (0x810705B0): <nativehr>0x810705b0</nativehr><nativestack></nativestack>This lookup column cannot enforce a relationship behavior because it contains values that reference one ore more non-existent items in the target list. at Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateField(String bstrUrl, String bstrListName, String bstrXML) at Microsoft.SharePoint.Library.SPRequest.UpdateField(String bstrUrl, String bstrListName, String bstrXML) --- End of inner exception stack trace --- at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.UpdateField(String bstrUrl, String bstrListName, String bstrXML) at Microsoft.SharePoint.SPField.UpdateCore(Boolean bToggleSealed) at Microsoft.SharePoint.SPField.Update() at MyApp.Features.Service.EntityBuilder.EntityBuilderBase.EnforceReferentialIntegrity()
顺便说一句,当在浏览器中字段的属性中单击“强制性关系行为”时,我会遇到完全相同的错误。
我已经看了反射器,但是这个错误正在不受管理的代码中发生,因此,如果有人能提供任何其他调试技术,我会很高兴。
谢谢 - 李
解决方案
清单中是否已经有项目?设置两个空列表时,这最有效。