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.

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

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

  • 1
    Can you check the apiversion in the xml file of the Case trigger and this class and make sure it's > = 46.0 – Manish Anand Jul 3 '20 at 16:21
  • Hey there Manish, That actually worked, I was running an older version. Thank you very much! – Chandrew Jul 6 '20 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. – Manish Anand Jul 10 '20 at 6:04

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

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.