You need to sign in to do that
Don't have an account?
Lili Chaves
Trigger to disable mass transfer
I need our reps to only be able to transfer ownership if the lead belongs to a queue, I was able to successfully to this with a validation. But because I have the "Transfer Leads" permission enabled it has exposed the "Mass Transfer" lead link on the Lead object.
So I am trying to write a trigger to prevent any profile other than System Administrator from being able to bulk transfer, but I have no idea what I am doing. Can someone help me with the code for this trigger?
This is what I have so far:
Trigger LeadMassTransfernotallowed on Lead (after update){
Id userProfileId = userinfo.getProfileId();
String userProfileName = [SELECT ID, Name from Profile Where Id = :userProfileId].Name;
for(Lead leadInsert: Trigger.new){
if(userProfileName <> 'System Administrator'){
//system.debug('my Oldvalue');
lead.adderror('You do not have the permission to mass transfer Lead Ownership, contact SalesOp')
if(trigger.new[0].OwnerId!=trigger.old[0].OwnerId){
}
}
}
}
So I am trying to write a trigger to prevent any profile other than System Administrator from being able to bulk transfer, but I have no idea what I am doing. Can someone help me with the code for this trigger?
This is what I have so far:
Trigger LeadMassTransfernotallowed on Lead (after update){
Id userProfileId = userinfo.getProfileId();
String userProfileName = [SELECT ID, Name from Profile Where Id = :userProfileId].Name;
for(Lead leadInsert: Trigger.new){
if(userProfileName <> 'System Administrator'){
//system.debug('my Oldvalue');
lead.adderror('You do not have the permission to mass transfer Lead Ownership, contact SalesOp')
if(trigger.new[0].OwnerId!=trigger.old[0].OwnerId){
}
}
}
}
Use this code and let me know if it works for. I have tested it seems to be working as expected.
Even though it shows that " 3 Leads Transferred " owner of those leads won't be changed, I just verified it. And you cannot redirect the user via trigger, if you want to redirect then you will have to develop custom UI ( VF page / Lightning Component ) for that.