You need to sign in to do that
Don't have an account?
Yamini Bathula
apex trigger not working for certain users
Hi Guys,
We have a before Update Trigger on Lead which fires on Lead conversion to check some mandatory values and just add error using Apex.adderror() method to display the error message to the user. This trigger is not firing for some users instead of trigger's error message they are getting an error message which is the result of a process builder which tries to update an Opportunity name when an Oporutnity is created. When I(system admin) login as them and try it is displaying the trigger's error message.
I am not sure what is happening.
Does any one have any idea or had the same issue?
We have a before Update Trigger on Lead which fires on Lead conversion to check some mandatory values and just add error using Apex.adderror() method to display the error message to the user. This trigger is not firing for some users instead of trigger's error message they are getting an error message which is the result of a process builder which tries to update an Opportunity name when an Oporutnity is created. When I(system admin) login as them and try it is displaying the trigger's error message.
I am not sure what is happening.
Does any one have any idea or had the same issue?
Can you please let us know if you are using any helper class for your trigger and If Yes. the what is the mode of your helper class. Is it With Sharing or Without Sharing? If you are not using any helper class then please post your trigger code here so that we can have a look and suggest something to you.
Thanks,
Abhishek Bansal.
Couple of questions -
1. Is there a reason all your validations are present in trigger? Can't you put all these in a Validation rule instead of Triggers as given above.
2. Have you enabled Validations and Triggers for Lead Convert in your organization?
3. Also, is the Process builder related to Lead conversion process?
Thanks,
Chellappa
Couple of questions -
1. Is there a reason all your validations are present in trigger? Can't you put all these in a Validation rule instead of Triggers as given above.
2. Have you enabled Validations and Triggers for Lead Convert in your organization?
3. Also, is the Process builder related to Lead conversion process?
Thanks,
Chellappa
Yes, We first tried with Validation rules. I cannot customise the Message for each field if I Use single validation rule. If i use multiple validation rules then they dont fire once. They will fire one after the other so it is difficult to the user every time they have to go to back page for every rule.
2. Have you enabled Validations and Triggers for Lead Convert in your organization? Yes
3. Also, is the Process builder related to Lead conversion process? Process builder updates the opportunity name when an opp is created. So in a way it is related to Lead Conversion as it creates an Opportunity too.
I can't see or figure out any reason that the trigger is not working for some users and for others it is working fine. However, one thing which I noticed is, you are adding the error on the basis of one condition i.e. if((l.ParentAccount__c != '0019000001YHuxWAAT') && (l.ParentAccount__c != '0016F00001i2yYHQAY')).
The users for which trigger is not working may be using leads where Parent Account is same as you have mentioned in the if condition. Can you please check this. Other than this I don't see any reason for the inconsistent behaviour of the trigger.
Thanks,
Abhishek Bansal.