0

I have a visualforce page using the Contact standard controller that's displaying a mix of Contact and Account fields. I have some of the Contact fields configured so you can update them directly from the page, but I was wondering if it's possible to update the Account fields from this page as well in the same fashion?

I added the same

<apex:inlineEditSupport event="ondblClick" /></apex:outputField>

portion to the field, and while it activates the field and let's me use the lookup, it doesn't actually save.

Is this possible?

<apex:page standardController="Contact" sidebar="false"  showheader="false">   
    <apex:form >
        <div style="width: 405px; margin: 0 auto; padding: 10px 0 10px 0">
            <div style="margin-right: 5px; width: 35px; display: inline"><apex:commandButton value="Save" action="{!quicksave}" id="saveButton" /></div>
            <button style="width: 120px; margin-right: 5px" onclick="window.open('https://www.linkedin.com/search/results/people/?company={!Contact.Account.Name}&firstName={!Contact.FirstName}&lastName={!Contact.LastName}')">Contact's LinkedIn</button>
            <button style="width: 120px; margin-right: 5px" onclick="window.open('https://www.linkedin.com/company/{!Contact.Account.Name}')">Account's LinkedIn</button>
            <button style="width: 100px" onclick="window.open('https://app.salesloft.com/app/import/crm?contact={!Contact.Id}')">SalesLoft Import</button>
        </div>    
        <apex:pageBlock >
            <apex:pageBlockSection title="Account Details" columns="2">

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Account Name"/>
                <apex:outputField value="{!Contact.Account.Name}"/>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Account Owner"/>
                <apex:outputField value="{!Contact.Account.Owner.Name}"/>
                </apex:pageBlockSectionItem>                                

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Account Type"/>
                <apex:outputField value="{!Contact.Account.Type}"/>
                </apex:pageBlockSectionItem>                

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Pipeline Rep"/>
                <apex:outputField value="{!Contact.Account.Pipeline_Rep__c}"><apex:inlineEditSupport event="ondblClick" /></apex:outputField>
                </apex:pageBlockSectionItem>                 

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Employees"/>
                <apex:outputField value="{!Contact.Account.NumberOfEmployees}"/>
                </apex:pageBlockSectionItem>                    

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Open Opps"/>
                <apex:outputField value="{!Contact.Account.No_of_Open_Opportunities__c}"/>
                </apex:pageBlockSectionItem>                           

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Closed/Won Opps"/>
                <apex:outputField value="{!Contact.Account.No_of_ClosedWon_Opportunities__c}"/>
                </apex:pageBlockSectionItem>                

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Closed/Lost Opps"/>
                <apex:outputField value="{!Contact.Account.No_of_ClosedLost_Opportunties__c}"/>
                </apex:pageBlockSectionItem>    

            </apex:pageBlockSection>        
            <apex:pageBlockSection title="Contact Details" columns="2">

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Record Type"/>
                <apex:outputText value="Contact"/>
                </apex:pageBlockSectionItem>            

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="First Name"/>
                <apex:outputField value="{!Contact.FirstName}"><apex:inlineEditSupport event="ondblClick" /></apex:outputField>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Title"/>
                <apex:outputField value="{!Contact.Title}"><apex:inlineEditSupport event="ondblClick" /></apex:outputField>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Last Name"/>
                <apex:outputField value="{!Contact.LastName}"><apex:inlineEditSupport event="ondblClick" /></apex:outputField>
                </apex:pageBlockSectionItem>                

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Email"/>
                <apex:outputField value="{!Contact.Email}"><apex:inlineEditSupport event="ondblClick" /></apex:outputField>
                </apex:pageBlockSectionItem>                           

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Phone"/>
                <apex:outputField value="{!Contact.Phone}"><apex:inlineEditSupport event="ondblClick" /></apex:outputField>
                </apex:pageBlockSectionItem>  

            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
0

It is not possible to save parent field (Account fields) using apex:outputField and apex:inlineEditSupport

To save parent field, you need to build a custom VF page with its controller.

Let me know if it helps

0

You cannot save both Contact and Account changes.

If you want to save both the Contact and Account field changes, you can override the "SAVE" method with your controller's custom method. And in that custom method, you can save contact and account records.

0

yes you can but you should use a controller extension for account data updation on save button.

<apex:page standardController="Contact" extensions="AccountDataController">
    |

    |
     <apex:commandButton action="{!saveme}" value="save"/>
    |
    |

in controller make a method

public void saveme(){

//do all the updation in account and all.

}

  • the controller would have to perform the updates for both the Contact and the Account, right? – Matt Jul 7 '17 at 17:52
  • yes, we can do it by save me method as i mentioned above – hasectic saif Jul 10 '17 at 19:25

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.