If I launch a visualforce page called 'My New Opportunity' from the Account page with fields like custom contact in it, I would like to create a Hyperlink with the words "Don't have a Contact?" just under/right of the custom contact field(which is a lookup). Clicking it should redirect to the contact creation url under that particular account. Can someone tell me how to achieve this? I am very new to visualforce and couldn't find anything like this.


Thanks for the help. I managed to do it on my own.

I first created a formula field on Account that returns the url of contact based on Account ID:

HYPERLINK("https://csxx.salesforce.com/003/e?retURL=%2F001500000xxxxem&accid="&Id&"&RecordType=0125xxxx000E7ay&ent=Contact","Click Here!")

Then I added this line to VF Page:

<apex:outputText value="{!Account.Hyperlink_for_Contact__c}" escape="false"/>

It isn't exactly what I wanted to achieve but if fulfills my purpose.


Considering you have the AccountId in your My New opportunity VF page, you can take things forward by taking a hint by creating a contact from within the standard Account page. It gives you a url like the one below:


The above URL is from my org and it uses a RecordType to create specific contact. You can ignore that and use a similar URL and dynamic AccountId, to create complete URL for the creation of new contact.

  • Looked at your solution after I solved it myself. Thanks for the help. – Rohith Raj Feb 22 '17 at 22:40

You can use pageblocksection item

  <apex:outlabel value="Your label" />
    <apex:inputfield value="{!ur Lookup Field}" />
    <apex:outputLink value="/newpage">Don't have a Contact?</apex:outputLink>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.