Cómo hacer valer los errores de integridad referencial Debido a la relación: “Contiene los valores que uno o más elementos de referencia que no existen en la lista de objetivos”

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/4691

  •  16-10-2019
  •  | 
  •  

Pregunta

Cuando trato de hacer cumplir la integridad referencial de esta manera:

fieldLookup.Indexed = true;
fieldLookup.RelationshipDeleteBehavior = SPRelationshipDeleteBehavior.Restrict
fieldLookup.Update()

Funciona para la mayoría, pero no todos los campos en mi aplicación. Cuando no se parece a esto:

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()

Por cierto, me sale este exactamente el mismo error al hacer clic en "Forzar el comportamiento relación" en las propiedades del campo en el navegador.

He mirado en el reflector, pero este error está ocurriendo en código no administrado, por lo que sería igual de feliz si alguien podría proporcionar algún técnicas de depuración adicional.

Gracias, - Lee

¿Fue útil?

Solución

¿Las listas tienen elementos en ellos ya? Esto funciona mejor cuando la creación de dos listas vacías.

Licenciado bajo: CC-BY-SA con atribución
scroll top