You need to sign in to do that
Don't have an account?
Dileep Katari
How to prevent a set of users from merging accounts using trigger? Please help fix this code
We are going to have a new permission set called "Supplier Merge Tool Access". Users who are assigned with this permission set should only be able to merge account records of record type "Supplier" and be blocked from merging any other records of other record types
Blocked scenarios
Supplier with record type A
Record Type A with Supplier
Not to be blocked
Supplier with Supplier
The below logic is working when Supplier record is the main account but when Supplier record is the dupe record, merge is happening. Ideally it should not
List<User> UserList = new List<User>();
UserList = [Select Id from User where Id IN(SELECT AssigneeId FROM PermissionSetAssignment WHERE PermissionSet.Name = 'Supplier_Merge_Tool_access')];
for(User u : UserList){
if (UserInfo.getUserId() == u.id) {
for(Account a : (List<Account>)olditems.values()) {
if( a.RecordType.Name != 'Supplier' ) {
a.addError('You are only authorized to merge a Supplier account with another Supplier account');
Blocked scenarios
Supplier with record type A
Record Type A with Supplier
Not to be blocked
Supplier with Supplier
The below logic is working when Supplier record is the main account but when Supplier record is the dupe record, merge is happening. Ideally it should not
List<User> UserList = new List<User>();
UserList = [Select Id from User where Id IN(SELECT AssigneeId FROM PermissionSetAssignment WHERE PermissionSet.Name = 'Supplier_Merge_Tool_access')];
for(User u : UserList){
if (UserInfo.getUserId() == u.id) {
for(Account a : (List<Account>)olditems.values()) {
if( a.RecordType.Name != 'Supplier' ) {
a.addError('You are only authorized to merge a Supplier account with another Supplier account');