I have created a Batch class and write a logic into execute method. In this logic I queried a Object (DuplicateRecordItem) . It's giving an error on saving the batch class Error:(sObject type 'DuplicateRecordItem' is not supported). I can not understand why this showing. My logic is below Please Help!

global void execute(Database.BatchableContext BC, List<DuplicateRecordSet> scope) {

    //call MergeAccounts method.

public static void  MergeAccounts(List<DuplicateRecordSet> dupset){

    Map<Id, DuplicateRecordSet> mapDuplicateRecordSet =  new Map<Id,DuplicateRecordSet>();

    for(DuplicateRecordSet drs : dupset){
        mapDuplicateRecordSet.put(drs.Id, drs);

    Map<Id, Set<Id>> mapDuplicateRecordItem =  new Map<Id, Set<Id>>();

    //here throwing error 
    for(DuplicateRecordItem drI : [SELECT Id,RecordId, DuplicateRecordSetId FROM DuplicateRecordItem where DuplicateRecordSetId In : mapDuplicateRecordSet.keyset()]){

            mapDuplicateRecordItem.put(drI.DuplicateRecordSetId, new Set<Id>{drI.RecordId}); 

    for(DuplicateRecordSet dr : [SELECT Id FROM DuplicateRecordSet where Id IN : mapDuplicateRecordItem.keyset()]){

        Set<Id>  setaccId =  mapDuplicateRecordItem.get(dr.Id);

        list<id> lstAccId = new list<id>(); 

        for(Account acc : [SELECT Id, name,BillingCountry, BillingState FROM Account where ID In : setaccId And OwnerId ='00540000002lBne' Limit 1]){

                merge acc lstAccId;

Make sure that your class is saved at API version 32.0 or above, DuplicateRecordItem did not come in until version 32.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.