You need to sign in to do that
Don't have an account?

Too many code statements: 200001
Guys - I have a trigger deployed to retrieve owner role of an opportunity. It's working fine but fails while mass updating opportunity. Can anyone help to make it a bulk trigger.
trigger OwnerRoleTrigger on Opportunity (before insert, before update) {
List<Opportunity> oppList = new List<Opportunity>();
List<string> ownerId = new list<string>();
list<String> userRole = new list<string>() ;
for(Opportunity opp1 : Trigger.New) {
ownerId.add(opp1.ownerId);
}
List<User> users = [select UserRoleId from User where Id in: ownerId];
for(User u : users){
userRole.add(u.UserRoleId);
}
List<UserRole> userRoles = [select Name from UserRole where Id in: UserRole];
for(Opportunity opp : Trigger.New) {
for(User u : users){
for(UserRole ur : userRoles){
opp.opp_owner_role__c = ur.Name;
}
}
}
}
Thanks a lot
Best Regards,
Vishal Sharma
Just try below once , i have not executed if any error comes syntex or runtime please let me know
I have executed just i done some mistake in syntax, i am correction below ----