Hi there,
I'm trying to delete a lookup field in a list using CSOM but it appears not to be possible.
Tryed the following combinations:
FieldLookup columnToDeleteLU = (FieldLookup)columnToDelete; columnToDeleteLU.DeleteObject(); list.Update(); ctx.ExecuteQueryandRetry();
OR
Field columnToDeleteLU = list.Fields.FirstOrDefault(x => x.Id == columnDelete) columnToDelete.DeleteObject(); list.Update(); ctx.ExecuteQueryandRetry();
And I always get the error:
The primary lookup field cannot be deleted. There are dependent lookups created on this primary lookup field that should be deleted first."
I tried to use the
var primaryFieldID = columnToDeleteLU.PrimaryFieldId; list.Fields.FirstOrDefault(x => x.Id == columnDelete).DeleteObject(); list.Update(); ctx.ExecuteQueryandRetry();
Also with no success. I'm a little stuck here. Any ideas?