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

I need help bulkifying this trigger
trigger SampleTriggger on User (before Update)
{
For (User u1 : Trigger.New)
{
UserTeamMember u = [SELECT UserId, User.Name FROM UserTeamMember where TeamMemberRole= 'xxx'
AND OwnerId=:u1.ID];
u1.SSS__c= u.UserId;
}
}
trigger SSSUpdate on User (before Update)
{
Map<Id,Id> mapUserTeamIdVsuserId = new Map<Id,Id>();
for(UserTeamMember u : [SELECT id,UserId,ownerid, User.Name FROM UserTeamMember where TeamMemberRole= 'xxx' AND OwnerId IN:Trigger.New]){
mapUserTeamIdVsuserId.put(u.OwnerId,U.UserId);
}
for(User u1 : Trigger.New){
if(mapUserTeamIdVsuserId.containsKey(u1.id)){
u1.SSS__c= mapUserTeamIdVsuserId.get(u1.id);
}
}
}
All Answers
to overcome the recursive error. create anothe class as below. modify the code below.
thanks,
Ramesh
@ashi- thanks. but when i copied this code i got the following error and cant seem to fix it :) - Error: Compile Error: expecting a semi-colon, found ')' at line 3 column 135
find the below updated code and try ths one.
public class LocationControl{
public static boolean inFutureContext = false;
}
the code is working i have tested.
let me know where its not working fo ryou
connect
pavanthetech@gmail.com
trigger SSSUpdate on User (before Update)
{
Map<Id,Id> mapUserTeamIdVsuserId = new Map<Id,Id>();
for(UserTeamMember u : [SELECT id,UserId,ownerid, User.Name FROM UserTeamMember where TeamMemberRole= 'xxx' AND OwnerId IN:Trigger.New]){
mapUserTeamIdVsuserId.put(u.OwnerId,U.UserId);
}
for(User u1 : Trigger.New){
if(mapUserTeamIdVsuserId.containsKey(u1.id)){
u1.SSS__c= mapUserTeamIdVsuserId.get(u1.id);
}
}
}