1

enter image description here SUMMARY:
I am currently implementing Merge Cases functionality and need to be able to edit fields on the losing and winning record during this process. Looking at the documentation depending on whether duplicates are kept Update and Delete triggers are fired and the way to identify this as a merge operation is to check the MasterRecordId field on the losing record.

I am unable to access the MasterRecordId during the merge Case process. This is true whether the merge maintains or deletes the duplicate record.

DECLARATIVE APPROACH:
When maintaining the duplicate I attempted to access it via Validation and Workflow rules (since maintaining duplicates only fires the Update Triggers, which is before the field gets populated). But the formula in the Validation field does not recognise the MasterRecordId field nor is it available to select in a workflow rule. enter image description here

PROGRAMMATIC APPROACH:
I have also attempted setting the merge to delete the losing record as the documentation implies that I would then be able to access the populated MasterRecordId field in the afterTrigger. Similar to the above paragraph that field is not available even through SOQL so I am unable to identify a merge process and make field updates accordingly

    public static void afterDelete(Map<Id,Case> oldMap, Map<Id,Case> newMap){
    system.debug('This is the after delete function');
    for(Case c : oldMap.values()){
        system.debug('THE DELETED CASES FROM THE MERGE: ' + c);
    }
    
    List<Case> mergedCases = [SELECT MasterRecordId FROM Case WHERE MasterRecordId != null ALL ROWS];
}

The debug in the above snippet does show the case I'm looking for but with the MasterRecordId field available and attempting to save gives us this error:
No such column 'MasterRecordId' on entity 'Case'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

I have also checked the API version my Salesforce is running it does appear to be a version after MasterRecordID was added (v46).

Any assistance with this would be greatly appreciated.

Sincerely, Andrew

3
  • 1
    Can you check the apiversion in the xml file of the Case trigger and this class and make sure it's > = 46.0 Commented Jul 3, 2020 at 16:21
  • Hey there Manish, That actually worked, I was running an older version. Thank you very much!
    – Chandrew
    Commented Jul 6, 2020 at 20:14
  • Great!!. I am adding it as an answer. Accept it so that it may be helpful if some one ends up in this thread with similar issue. Commented Jul 10, 2020 at 6:04

1 Answer 1

2

MasterRecordId is available in Case in the api version > = 46.0. If it is used in any class or trigger , make sure it's xml file has apiversion >= 46.0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .