You need to sign in to do that
Don't have an account?
pranavshah
Lead Code Explaination
Can anyone explain me below line of codes
public class myWeb2LeadExtension
{
private final Lead weblead;
public myWeb2LeadExtension(ApexPages.StandardController stdController)
{
weblead = (Lead)stdController.getRecord();
}
public PageReference saveLead() {
try
{
insert(weblead);
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
PageReference p = Page.ThankYou;
p.setRedirect(true);
return p;
}
public class myWeb2LeadExtension
{
private final Lead weblead;
public myWeb2LeadExtension(ApexPages.StandardController stdController)
{
weblead = (Lead)stdController.getRecord();
}
public PageReference saveLead() {
try
{
insert(weblead);
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
PageReference p = Page.ThankYou;
p.setRedirect(true);
return p;
}
Basically this code is extension class for your standard controller Lead. Please find explanation of each line in comment Please let me know if helped.
Regards,
Ramakant
All Answers
Basically this code is extension class for your standard controller Lead. Please find explanation of each line in comment Please let me know if helped.
Regards,
Ramakant
will you please explain these.. this code is for inserting opportunity amount and updating the field on Account
public class opportunityhandler
{
public void opportunityamount(list<opportunity> newopportunity)
{
set<Id> setOppName=new set<Id>();
List<Account> lstActs =new list<Account>();
List<Opportunity> opps=new list<Opportunity>();
for(opportunity opp:newopportunity)
{
setOppname.add(opp.Accountid);
}
list<Account> LstAccs= [select id,Name,Total_Opportunity_Amount__c,(select id, Amount from opportunities) from account where Id IN:setOppname];
for(Account acc: lstAccs)
{
double TotalAmount=0;
for(Opportunity opp:acc.opportunities)
{
if(opp.Amount!=null)
{
totalAmount=TotalAmount+opp.Amount;
}
}
acc.Total_Opportunity_Amount__c=totalAmount;
lstacts.add(acc);
}
update lstacts;
}
}