I need to update a lot of record to change their lookup field to null, I tried following code:
public class UpdateContact implements Database.Batchable<sObject>{
public Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator([Select id, Profil__c from Contact__c]);
}
public void execute(Database.BatchableContext BC, List<Contact__c> scope){
for(Contact__c contactC:scope){
contactC.Profil__c = null;
update ContactC;}}
public void finish(Database.BatchableContext BC){
} }
But this code isn't working, I got the following error: First error: Invalid id:
So Apex is not considering null as an id, but I want to turn that Profil field to empty could you help me to do it ?
Thank you for your answers.