You need to sign in to do that
Don't have an account?
saravana kumar 106
Hi folks i am new to salesforce, need to replika lead object edit page and i done wih save function using controller based on my requirement, but i am not able to replicate save&view button
<apex:commandButton value="Save & New" action="{!recordSaveandNew}"></apex:commandButton>
public PageReference recordSaveandNew()
{
convertLeadRecord();
//this code will redirect to home page but i need to redirect new lead page
PageReference pg =new PageReference(Url.getSalesforceBaseUrl().toExternalForm());
return pg;
}
public PageReference recordSaveandNew()
{
convertLeadRecord();
//this code will redirect to home page but i need to redirect new lead page
PageReference pg =new PageReference(Url.getSalesforceBaseUrl().toExternalForm());
return pg;
}
if i am not wrong you want to save the record and redirect it to the lead rocord page. is it?
Please correct me if it is something else.
thanks
I need to show create new lead page after clicking, I am using vf standard controller page for lead edit and I replicate all view as it is salesforce default lead edit page,
after clicking Save & New button it should save update lead record and show neawlead creation page,
Expected page,
based on my code am getting home page,
PageReference pg =new PageReference(Url.getSalesforceBaseUrl().toExternalForm());
return pg;
I need to load the expected page.
Thank again.
I looked at your issue and found this solution. I have also mentioned the link from where I have got this solution.
It should work fine for you.
Link - https://developer.salesforce.com/forums/?id=906F000000095GEIAY
public PageReference saveAndNew(){
try {
save();
Schema.DescribeSObjectResult result = ClassName.getRecord().getSObjectType().getDescribe();
PageReference pr = new PageReference('/' + result.getKeyPrefix() + '/e?' + queryString);
pr.setRedirect(true);
return pr;
} catch(System.DMLException e) {
System.debug('Error - '+e.getmessage()+' in line number - '+e.getLineNumber());
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com