You need to sign in to do that
Don't have an account?
page redirection...
hai all,Thanks in advance..
I have a small problem,but i could nt understand how to do it.please help me.
I want to redirect to google page only when the record is inserted.here in this code always it is redirecting after clicking on save.if the error message will come means it wont redirect...
public class loginfortestController {
public LoginDetailsforTest__c opp{get;set;}
public loginfortestController() {
opp=new LoginDetailsforTest__c();
}
public pagereference save()
{
for(list<logindetailsfortest__C> lt:[select email__C from logindetailsfortest__C where email__c=:opp.email__c limit 1])
{
system.debug(lt);
if(opp.email__c==null||!lt.isempty())
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'enter another email id');
ApexPages.addMessage(myMsg);
PageReference pageRef = ApexPages.currentPage();
}else{
LoginDetailsforTest__c ldt=new LoginDetailsforTest__c(user_name__c=opp.user_name__c,email__c=opp.email__c);
insert ldt;
}
}
pagereference ref=new pagereference('https://www.google.com');
return ref;
}
}
CHange your code to this
Hope this will work now
All Answers
CHange your code to this
Hope this will work now
Simpliest way without getting into much complexity is having your page ref be inside your else statement with the google redirect. This should handle any validation rules as well and display it on the page incase the insert fails. This has not been tested but I'm pretty sure it should work just fine. Just my personal disclamer.
first thing you need write setredirect = true
second thing is any thing will go through salesforce server so pan your url to meet that condition.
pagereference ref=new pagereference
('https://www.google.com');ref.setredirect(true);
return ref;
if this answers your question, Make this as solution
Thanks Rohit.
Thanks Alex.