function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shubham SengarShubham Sengar 

Visualforce page Problems

 When u click on New Button (Account Page) its goes to A VF Page where 3 fiels like Account Name ,Account Number ,Account Phone No
 and one Save Button...............................
<apex:page standardController="Account">
  
     <apex:form >  
     <apex:pageBlock >    
     <apex:pageBlockButtons >
       <apex:commandButton value="Save" action="{!save}"/>
  <apex:commandButton action="{!cancel}" value="Cancel"/>
     </apex:pageBlockButtons>
   
   <apex:pageBlockSection title="Enter Account Details">        
          <apex:inputField value="{!Account.Name}"/>            
          <apex:inputField value="{!Account.accountNumber}"/> 
          <apex:inputField value="{!account.Phone}"/>
    </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>.........
 When u click on Save Button (VF Page) ​​it will goes to another new VF page Where Account Name Auto Populated With a ("Go To Contact") Button .......................
<apex:page standardController="Account" extensions="Contact">
<apex:form >
 <apex:pageBlock >
 <apex:pageBlockButtons >
 <apex:commandButton value="GoToContact" action="{!Contact1}"/>
 </apex:pageBlockButtons>
    <apex:pageBlockSection title="Account Details">
         <apex:outputField value="{!Account.Name}"/>
         <apex:outputField value="{!Account.accountNumber}"/> 
          <apex:outputField value="{!account.Phone}"/>
     </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:form>
  </apex:page>

and class code is ..

public with sharing class Contact {
   public Account a{get; set;}
    public Contact(ApexPages.StandardController controller) {
       }
      string id =  Apexpages.currentpage().getParameters().get('id');
    public pagereference contact1()
    {
    PageReference requestPage = new pagereference('https://ap2.salesforce.com/003/o'+a);
        return page.contactpage.setredirect(true);
    }
 }

 When u click on "​Go To Contact" Button it will goes to contact detail page(custome vf page) where  Account Name ,Account Number ,Account Phone No will populated in new contact ..

Hear i am facing problem ....

<apex:page standardController="Contact" extensions="Contact">
  <apex:form >  
     <apex:pageBlock >    
     <apex:pageBlockButtons >
       <apex:commandButton value="Save" action="{!save}"/>
       
   </apex:pageBlockButtons>
       <apex:pageBlockSection title="Enter Contact Details">   
          <apex:inputField value="{!Contact.id}"/>   
            
         <apex:outputField value="{!contact.Account.Name}"/>
          <apex:inputField value="{!Contact.Name}"/>         
          <apex:inputField value="{!Contact.Phone}"/>   
        </apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
  </apex:page>

n class code 
public with sharing class Contact {
   public Account a{get; set;}
    public Contact(ApexPages.StandardController controller) {
   
         
      }
      string id =  Apexpages.currentpage().getParameters().get('id');
    public pagereference contact1()
    {
    PageReference requestPage = new pagereference('https://ap2.salesforce.com/003/o'+a);
        return page.contactpage.setredirect(true);
    }
 }

 
William TranWilliam Tran
Not sure what the issue is but try this:

PageReference requestPage = new pagereference('https://ap2.salesforce.com/'+a);
requestPage.setRedirect(true);
return requestPage;

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you. 

Thanks
Shubham SengarShubham Sengar
Thanks William 

the problem is when i click GO TO CONTACT button the same data which we entered in account comes in contact detail page ( custome vf page)

according to your link when m clicking on  GO TO CONTACT button ,i'm getting this 

URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com. 

You may have reached this page after clicking on a direct link into the application. This direct link might be: 
• A bookmark to a particular page, such as a report or view 
• A link to a particular page in the Custom Links section of your Home Tab, or a Custom Link 
• A link to a particular page in your email templates 
William TranWilliam Tran
did you try my code above: 

PageReference requestPage = new pagereference('https://ap2.salesforce.com/'+a);

what you have is this:

https://na24.salesforce.com/003/o0031a00000AXDBf

what you want is this:

https://na24.salesforce.com/0031a00000AXDBf

that is remove "003/o"

otherwise can you post what is in your URL.

thx
Shubham SengarShubham Sengar
Hi william

now i m using ur code like public with sharing class Contact {
   public Account a{get; set;}
    public Contact(ApexPages.StandardController controller) {
   
         
      }
      string id =  Apexpages.currentpage().getParameters().get('id');
    public pagereference contact1()
    {
   
PageReference requestPage = new pagereference('https://ap2.salesforce.com/'+a); // also try https://ap2.salesforce.com/003/o this one 
requestPage.setRedirect(true);
return requestPage;

    }
 }
 

but its showing error 
URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com. 

You may have reached this page after clicking on a direct link into the application. This direct link might be: 
• A bookmark to a particular page, such as a report or view 
• A link to a particular page in the Custom Links section of your Home Tab, or a Custom Link 
• A link to a particular page in your email templates 

If you reached this page through a bookmark, you are probably trying to access something that has moved. Please update your bookmark. 

If you reached this page through any of the other direct links listed above, please notify your administrator to update the link. 

If you reached this page through a link on our site, please report the broken link directly to our Support Team and we will fix it promptly. Please indicate the page you were on when you clicked the link as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com!
William TranWilliam Tran
cut and paste you URL, what does your variable "a" return?

You might need to change it to a.id

thx
Shubham SengarShubham Sengar

Hi william,

plz suggest me how to pass the id by url -----like by passing account id i want to create contact 

in our case  my code is.........

public with sharing class Contact {
   public Account a{get; set;}
    public Contact(ApexPages.StandardController controller) {
   
         
      }
      string id =  Apexpages.currentpage().getParameters().get('id');
    public pagereference contact1()
    {

PageReference requestPage = new pagereference('https://ap2.salesforce.com/'+a);
requestPage.setRedirect(true);
return requestPage;

    }
 }

may be wrong this one plz suggest right one i m stuck the last step last 2 days so ..