can you give me more insights how do you trying to achieve? i mean trying to update the existing data or you want to do it with the trigger for new records?
You can do it even with the process builder and trigger
trigger Lead1 on Lead (before insert) {
for( Lead l : Trigger.new){
l.LastName ='CA-Lead'+''+System.today().day() +''+System.today().month()+''+System.today().year();
}
}
Please refer to below code.
List<Lead> listOfLead = new List<Lead>();
date startDate = date.parse('01/01/2018');
Date endDate = System.Today();
for(dateTime d=startDate ; d<=endDate; d=d.addDays(1)){
string dateFormate = d.formatGmt('MM'+'dd'+'yyyy');
system.debug(dateFormate);
Lead ld = new Lead();
ld.LastName ='CA-Lead-'+dateFormate;
ld.Company='CA-Company-'+dateFormate;
ld.Status='Working-Contacted';
listOfLead.add(ld);
}
if(listOfLead.size()>0){
insert listOfLead;
System.debug('list of leads'+listOfLead);
}
Please mark it as best if you find it helpful.
Thank You
Ajay Dubedi
All Answers
You can do it even with the process builder and trigger
Please refer to below code.
List<Lead> listOfLead = new List<Lead>();
date startDate = date.parse('01/01/2018');
Date endDate = System.Today();
for(dateTime d=startDate ; d<=endDate; d=d.addDays(1)){
string dateFormate = d.formatGmt('MM'+'dd'+'yyyy');
system.debug(dateFormate);
Lead ld = new Lead();
ld.LastName ='CA-Lead-'+dateFormate;
ld.Company='CA-Company-'+dateFormate;
ld.Status='Working-Contacted';
listOfLead.add(ld);
}
if(listOfLead.size()>0){
insert listOfLead;
System.debug('list of leads'+listOfLead);
}
Please mark it as best if you find it helpful.
Thank You
Ajay Dubedi