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

Based on below class i want to update All Leads in the system how it is possible ?
trigger Lead_Update on Lead (before insert,before update) {
String dam ='';
String jub='';
String west1 ='';
String west2 = '';
String central = '';
String Gcc = '';
/*Public String uid=UserInfo.getUserId();
public user UserDetails = [select User.Location__c from User Where User.Id =:uid limit 1];
public string UserLoc= UserDetails.Location__c;
// System.debug(UserLoc);*/
for(Lead lt : trigger.new){
String uid=UserInfo.getUserId();
user UserDetails = [select User.Location__c from User Where User.Id =:uid limit 1];
string UserLoc= UserDetails.Location__c;
// system.debug('---------------------Location------------------'+location);
lt.Region__c = UserLoc;
}
}
String dam ='';
String jub='';
String west1 ='';
String west2 = '';
String central = '';
String Gcc = '';
/*Public String uid=UserInfo.getUserId();
public user UserDetails = [select User.Location__c from User Where User.Id =:uid limit 1];
public string UserLoc= UserDetails.Location__c;
// System.debug(UserLoc);*/
for(Lead lt : trigger.new){
String uid=UserInfo.getUserId();
user UserDetails = [select User.Location__c from User Where User.Id =:uid limit 1];
string UserLoc= UserDetails.Location__c;
// system.debug('---------------------Location------------------'+location);
lt.Region__c = UserLoc;
}
}
Deactivate your trigger.
And make a new class as shown. Then in anonymous window, write:
cls.UpdateAllLeads();
This will update all your leads according to your requirement
Let me know if it helps
Thanks!
Can you explain your requirement a bit more clearly please? I am not able to undestand your requirement.
You can apply filters to the SOQL query in the code, something like this.
[Select id, name ,Region__c from lead where createddate<today];
Note: The filters will depend upon your requirement.
I wounldn't suggest you doing what you want to do in your trigger. Because your trigger will fail incase the numbers of records are large.
Through data loader also if you try to insert more than 100 records, your trigger will hit the SOQL governor limit, because your code is not bulkified.
You can practice for triggers from here: https://tekslate.com/15-sample-triggers-different-scenarios/