You need to sign in to do that
Don't have an account?
Deepak Tumkur Shivanandaiah
Save function is not setting the values Using StandardSetController
Hey,
Here is the requirement.
Basically I have to add a button to the Contact related list in the Account Layout. When that button is clicked it sould redirect to a Visualforce Page with all the related Contacts and the contact details for that Account and the details should be editable with a save button.
Its basically Mass Update for Related List Details.
I was able to get all related contacts and give inline edit support for them and wrote a save function for the same. I don't know what is wrong but you can edit but when you click save it wont save to salesforce DB.
Here is the controller,
Here is the Visualforce page,
HELP!! Thanks In Advance! Cheers!
Here is the requirement.
Basically I have to add a button to the Contact related list in the Account Layout. When that button is clicked it sould redirect to a Visualforce Page with all the related Contacts and the contact details for that Account and the details should be editable with a save button.
Its basically Mass Update for Related List Details.
I was able to get all related contacts and give inline edit support for them and wrote a save function for the same. I don't know what is wrong but you can edit but when you click save it wont save to salesforce DB.
Here is the controller,
public class stanset_EX_Controller1{ private final Contact setCon; public stanset_EX_Controller1(ApexPages.StandardSetController controller) { this.setCon = (Contact) controller.getRecord(); } List<Contact> Conts; public List<Contact> getConts(){ return Conts; } public ApexPages.StandardSetController doSomething{ get { // do something with the selected records doSomething = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Phone, Name, AccountId, Email, FirstName, Id, LastName, Title FROM Contact WHERE AccountId = :ApexPages.currentPage().getParameters().get('id') ])); return doSomething; } private set; } public List<Contact> getAccountContactsPagination() { //system.debug(doSomething.getRecords()+'ppp'); return (List<Contact>) doSomething.getRecords(); } public PageReference save() { system.debug(getAccountContactsPagination()); //update(getAccountContactsPagination()); PageReference pageRef = ApexPages.currentPage(); pageRef.setRedirect(true); return pageRef; } }
Here is the Visualforce page,
<apex:page standardController="Contact" recordSetVar="contacts" extensions="stanset_EX_Controller1" showHeader="true" sidebar="false"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!accountContactsPagination}" var="contact"> <apex:column value="{!contact.name}"/> <apex:column value="{!contact.FirstName}"/> <apex:column value="{!contact.LastName}"/> <apex:column value="{!contact.Title}"/> <apex:column value="{!contact.Id}"/> <apex:column> <apex:outputField value=" {!contact.Email}"> <apex:inlineEditSupport disabled="false"/> </apex:outputField> </apex:column> <apex:column value="{!contact.Phone}"/> <apex:inlineEditSupport /> </apex:pageBlockTable> <apex:pageBlockButtons location="bottom"> <!-- <apex:commandButton value="Do Something" action="{!doSomething}"/> --> <apex:commandButton value="Save" action="{!save}" /> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>Tried many things dont know what is wrong with the code.
HELP!! Thanks In Advance! Cheers!
Below is a code for the same. Screenshot :
Hope It will help you!
Regards,
Akshay
Here is the code for your requirement.
I have an Object naming Expense below which I am having the object Expense Item.
This is the code for mass updating the Expense Item from the related list of the Expense Object.
Thanks for the quick reply mate. I knew how to do with a custom controller. But the thing was I had to give Pagination as well and it should take inputs from the user so that they can set how many records they want to see. Because of this I had to use StandardSetController which gives very easy pagination.
Thanks for the reply tough, I was able to get it done 1hr later i posted the question. My code was pretty much ok. The problem was that i used apex:pageBlockButtons tag for button and for some reason it was not working and my save function was was a bit off. All I had to use was .Save();.
Thanks you very much here is the code, same as above and some parts alterd.
VF Page:
StandardSetController: Need to do pagination for the same.
Thnaks hope it helps you.
Cheers!