1

I have created a visualforce page for our Lead Details page that displays Account information along with Lead information. I want to be able to save whatever changes our reps may make to the Account in that visualforce page (I have inline editing enabled). Is there a way to do this while still using the Lead standardController?

Thanks in advance!

  • I should preface this with the fact that we have an artificial link in our Salesforce instance that connects Leads to Accounts (so every lead is part of an account). – Justin Jun 25 '14 at 17:09
  • Are you storing the Account information in any way in the Controller or is it simply using the relationship between them? – Minutiae Jun 25 '14 at 17:23
  • For the sake of simplicity, I wanted to use the link between them. Take the following field output for example: <apex:outputField value="{!Lead.Account__r.AE_Rep__c}"> <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField> – Justin Jun 25 '14 at 17:30
  • In this case the standardController for the Lead will not save any changes to the Account. You'll have to update the Account in the Controller on save. – Minutiae Jun 25 '14 at 17:34
  • @Minutiae By "update the Account in the Controller on save", is this possible in the same visualforce page code? And if so, how would I go about doing that? – Justin Jun 25 '14 at 17:44
1

Technically I should've said Controller Extension. You can read a little about them here

You would get the Lead record in the Constructor similar to what is shown in that link. You would need to do a SOQL query for all the Account fields you will be working with and store them in an Account sObject.

On the Visualforce pages you would reference the Account fields using the Extension variable.

Override the Save button by creating a save method of your own. In here you can place DML statements for updating the Lead and Account as needed.

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.