function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shabuthomasshabuthomas 

Locating an undeleted record

Requirement: I have created a record (ID:ax.....01) for object 'Test' with the values for three key fields field1, field2 and field3 as 'aaa', 'bbb' and 'ccc'  (I've explicitly fixed this key so that there should be only one record for this combination key). Then I have deleted it. Again, I have ceated the same type of record (ID: ax.......02). Then, I'm going to undelete record in the  recycle bin (Id: ax......01). This yndeletion should not be allowed as I've recreated the record with same values.

What I have done: In after undelete trigger, I 've queried all records from Test (with out using ALL ROWS, just normal query). Surely, it will contain records with ID ax.....01 and ax.....02. But, since the combination key for both records are same, I've thrown an exception and undeletion was not allowed.

Problem of current implementation: If I undelete more than one recordof Test and undeletion of one record won't result in duplication and but the undeletion of other record will cause duplication, my implementation should not allow both undeletion.

What I need: In after undelete trigger, I should be able to differentiate the records recreated after undeletion.

Problem of ALL ROWS: Even if my organization's recyle bin was empty, when I tried to query all records using ALL ROWS, it showed all previously PERMANENTLY deleted records. So I could not differentiate the intended undeleted record.

Would somone please comment on this ?