0

This question already has an answer here:

The new button in Contact related list on the Account page points to a VF page which serves as an extra step to create a new Contact (to require them to enter certain info).

Normally, when the new button is standard, AccountId is valued on the new Contact record.

How can I get that AccountId to my controller so I can set it on the new Contact record?

marked as duplicate by glls, Mohith Shrivastava apex Feb 9 '18 at 17:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    can you share what you have tried so far? – glls Feb 6 '18 at 15:37
  • String id = stdController.getRecord().Id; Comes back as null. – SkipVV Feb 6 '18 at 15:47
  • String id = ApexPages.currentPage().getParameters().get('id'); --- Also null – SkipVV Feb 6 '18 at 16:03
  • So are you wanting to pass the id from vf to your apex controller? – M guy Feb 6 '18 at 16:33
  • When the VF page is loaded it will fire the constructor of the controller. I want to have the AccountId available there. – SkipVV Feb 6 '18 at 16:59
0

Thanks @rony joseph

/apex/YourVisualForcePage?acctId={!Account.Id}

I created a New Contact button on the Account. Content Source = URL with the above url.

I was getting hung up on trying to do this from a Contact Related List button. I don't think it is possible to get Account Id from a Contact Related List button on the Account detail page. It has to be a Detail Page Button on the Account object.

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