+ Start a Discussion
Gheorghe Sima 11Gheorghe Sima 11 

Open a visualforce page from other visualforce page

Hi,
I have a visualforce page for a new record. When the user click save, if he try to save an existing record I want to open a visualforce page with information about that record and tell him that the record already exists in database.
Can anyone explain me how it does?
Himanshu ParasharHimanshu Parashar
Hi Sima,

If you have Save method at controller side you can use following method
 
//Check for existing record here and then redirect.
PageReference newocp = new PageReference('/apex/secondpage');
newocp.setRedirect(true);
return newocp;

Makes sense?

Thanks,
Himanshu
Gheorghe Sima 11Gheorghe Sima 11
I know to do that. Let me explain you better what is my question. I have a custom button 'New Contact'  on Account . After user click save I check the information and if the contact already exist in the Database i what to return a visualforce page with the existing record information.
I don't know how can i obtain the information about existing record in the new page.
I hope you understood my problem :D
Himanshu ParasharHimanshu Parashar
Hi Sima,

Sorry I am bit confused here. Here is what I understood.

You have New Contact button on Account, when you click that button it opens a new vf page where you create a contact and when you click Save button on that page you want to open another page with all the exisitng contact with matched criteria.

is it correct ?

 
Gheorghe Sima 11Gheorghe Sima 11
When the user click save I check if the contact already exist in Database. If it doesn't exist then I insert it, but if it exist I want to show the information about it in a new page and let the user to decide if he will use or not  the existing contact.