You need to sign in to do that
Don't have an account?
aapt.dev
How to save mass edited records in a VF page
Hi
I'm trying to mass edit Contacts related to an account but am having problems with saving the changes to the records.
My APEX class:
public class accountContactList {
public accountContactList(ApexPages.StandardController controller) {
}
public Account getAccount() {
return [select id, name,
(select id, name, firstName, lastName, title, phone, mobilePhone, email from Contacts limit 5)
from Account where id =
:ApexPages.currentPage().getParameters().get('Id') ];
}
public String getName() {
return 'Account Contact List';
}
public PageReference save() {
return null;
}
}
public accountContactList(ApexPages.StandardController controller) {
}
public Account getAccount() {
return [select id, name,
(select id, name, firstName, lastName, title, phone, mobilePhone, email from Contacts limit 5)
from Account where id =
:ApexPages.currentPage().getParameters().get('Id') ];
}
public String getName() {
return 'Account Contact List';
}
public PageReference save() {
return null;
}
}
My VF page:
<apex:page standardController="Contact" extensions="accountContactList" id="thePage"
<apex:pageBlock title="Mass Edit Contacts">
</apex:pageBlock>
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" id="theButton"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!account.Contacts}"
var="contact">
<apex:column value="{!contact.name}" width="25" />
<apex:column headerValue="Title" width="100">
<apex:inputField value="{!contact.title}"/>
</apex:column>
<apex:column headerValue="Phone" width="15">
<apex:inputField value="{!contact.phone}"/>
</apex:column>
<apex:column headerValue="Mobile" width="15">
<apex:inputField value="{!contact.mobilephone}"/>
</apex:column>
<apex:column headerValue="E-Mail" width="25">
<apex:inputField value="{!contact.email}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
</apex:pageBlock>
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" id="theButton"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!account.Contacts}"
var="contact">
<apex:column value="{!contact.name}" width="25" />
<apex:column headerValue="Title" width="100">
<apex:inputField value="{!contact.title}"/>
</apex:column>
<apex:column headerValue="Phone" width="15">
<apex:inputField value="{!contact.phone}"/>
</apex:column>
<apex:column headerValue="Mobile" width="15">
<apex:inputField value="{!contact.mobilephone}"/>
</apex:column>
<apex:column headerValue="E-Mail" width="25">
<apex:inputField value="{!contact.email}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
I am getting the following error message:
Id value 0018000000Mif1y is not valid for the Contact standard controller (the ID being that of the account)
Any guidance would be much apprecaited from this newbie
Thanks in advance
And the VF page:
One caveat, I'm relatively new to this stuff myself and there may be an entirely easier way just using the standard controller
Message Edited by DManelski on 01-01-2009 11:14 PM
http://www.x2od.com/2008/11/13/project-change-owner-button-in-visualforce.html
Message Edited by DManelski on 01-01-2009 11:20 PM