I have a set of records supplier__c
which have a lookup to an address__c
record.
So I'd like to gather all those up:
//Make a list of ID's of addresses on Suppliers : supadrs
List<Id> supadrs = [ SELECT Address__c FROM Supplier__c ];
Then lets gather all the address__c
ids:
//Make a list of all address IDs : adrids
List<Id> adrids = [ SELECT Id FROM Address__c ];
And let's find all the address ids which are not on a supplier record:
//Make a list of ID's in List 2 which are not in List 1 and assign to List 3
list< Id > deletelist =[ SELECT Id FROM adrids where Id not in:supadrs ];
And then delete the list:
delete deletelist;
What would be the correct syntax for this action?