You need to sign in to do that
Don't have an account?
amit wagaskar
what i need to add here so that this controller will throw an error on VF page if lead is creating without an attachment
//my controller
controller:
public class myWeb2LeadExtension {
private final Lead weblead;
private ID Leadid;
public myWeb2LeadExtension(ApexPages.StandardController
stdController) {
this.weblead = (Lead)stdController.getRecord();
this.Leadid = stdController.getId();
}
@testvisible transient private Attachment myfile;
public Attachment getmyfile() {
myfile = new Attachment();
return myfile;
}
public PageReference saveLead() {
try {
weblead.LeadSource='Job Application Non-India';
weblead.Company='added from Job Application Page';
weblead.Status='open';
insert(weblead);
Attachment a = new Attachment(parentid=weblead.id, Name = myfile.name , Body = myfile.Body );
insert a;
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
PageReference p = Page.ThankYou;
p.setRedirect(true);
return p;
}
}
controller:
public class myWeb2LeadExtension {
private final Lead weblead;
private ID Leadid;
public myWeb2LeadExtension(ApexPages.StandardController
stdController) {
this.weblead = (Lead)stdController.getRecord();
this.Leadid = stdController.getId();
}
@testvisible transient private Attachment myfile;
public Attachment getmyfile() {
myfile = new Attachment();
return myfile;
}
public PageReference saveLead() {
try {
weblead.LeadSource='Job Application Non-India';
weblead.Company='added from Job Application Page';
weblead.Status='open';
insert(weblead);
Attachment a = new Attachment(parentid=weblead.id, Name = myfile.name , Body = myfile.Body );
insert a;
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
PageReference p = Page.ThankYou;
p.setRedirect(true);
return p;
}
}