Errore Enforcing integrità referenziale A causa di relazione: “Contiene i valori che uno o più elementi di riferimento inesistenti nella lista degli obiettivi”

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

  •  16-10-2019
  •  | 
  •  

Domanda

Quando si tenta di applicare l'integrità referenziale in questo modo:

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

Si lavora per la maggior parte, ma non tutti i campi nella mia app. Quando non riesce assomiglia a questo:

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

Per inciso, ottengo questo esattamente lo stesso errore quando fai clic su "Applica comportamento di relazione" nelle proprietà del campo nel browser.

Ho guardato in Reflector, ma questo errore sta accadendo in codice non gestito, quindi sarei altrettanto felice se qualcuno potesse fornire eventuali ulteriori tecniche di debugging.

Grazie, - Lee

È stato utile?

Soluzione

Non le liste hanno elementi in loro già? Questo funziona meglio quando si imposta su due liste vuote.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top