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
ChickenOrBeefChickenOrBeef 

REQUEST: Editable VisualForce contact list within Account page

Hey everyone,

We have five checkbox fields on the Contact object called:
  • Main User
  • General User
  • Signature Contact
  • Billing Contact
  • Stakeholder
We want to have a VisualForce page embedded on the Account page that lists all the Contacts on that respective Account along with a column for each of the checkbox fields, showing the current values. So it would look like this:

User-added image

It would be ideal if the user can just visit a certain Account, scroll down to the embedded VisualForce table (seen above), check and uncheck any boxes they need to, and then click Save, which would update the values on the Contacts. If the user needs to click an "Edit" button first in order to check/uncheck any boxes, then that would fine (but not ideal obviously).

I would be hugely appreciative if someone could provide example VisualForce and Controller code for something like this.  I have minor experience with VisualForce, but this is a step above what I've done. 

Thanks!
Greg 
Best Answer chosen by ChickenOrBeef
ChickenOrBeefChickenOrBeef
I figured this out on my own.

VisualForce page:
<apex:page standardController="Account" Extensions="ControllerContactSelectionAccount">
    
    <apex:form >
    
        <apex:pageBlock >
        
            <apex:pageBlockTable style="width:1500px" value="{!contacts}" var="Con">
            
                <apex:column value="{!Con.Name}"/>
                <apex:column headerValue="Main User" style="width:80px">
                    <apex:inputField value="{!Con.Main_User__c}"/>
                </apex:column>
                <apex:column headerValue="General User" style="width:80px">
                    <apex:inputField value="{!Con.General_User__c}"/>
                </apex:column>
                <apex:column headerValue="Billing" style="width:80px">
                    <apex:inputField value="{!Con.Billing__c}"/>
                </apex:column>
                <apex:column headerValue="Signature" style="width:80px">
                    <apex:inputField value="{!Con.Signature__c}"/>
                </apex:column>
            
            </apex:pageBlockTable>
            
            <Apex:pageBlockButtons location="bottom">
            
                <apex:commandButton action="{!customSave}" value="Save"/>
            
            </Apex:pageBlockButtons>
        
        </apex:pageBlock>
    
    </apex:form>
    
</apex:page>


Extension:
public class ControllerContactSelectionAccount{
    
    public List<Contact> contacts {get; set;}
    
    public ControllerContactSelectionAccount(ApexPages.StandardController controller){
        
        contacts = new List<Contact>();          
        Account Record = (Account) controller.getRecord();
        
        FOR(Contact c : [SELECT 
                             	Id, 
                             	Name,
                         	    Main_User__c, 
                             	General_User__c,
                             	Billing__c,
                             	Signature__c
                             FROM 
                             	Contact 
                             WHERE 
                             	AccountId = :Record.Id]){
        
            contacts.add(c);
            
        }
        
    }
    
    public PageReference CustomSave(){
    
        UPDATE contacts;
        
        RETURN null;
        
    }

}

-Greg