You need to sign in to do that
Don't have an account?

Override the save button for custom setting
Hi all,
I have an issue, I think ut is simple but I could not do it, I hope you could help me,
Here is the issue,
I made a vf page to display the value fields of a list custom setting "csObject__c" and editing its fields.
I want to make only one record which name="param" where i will modify its fields from the vf page, it's like in the beginning I put only the name 'param' in custom settings, then I can modify the other fields, the important it should be one only record which is Name='param'
<apex:page standardController="csObject__c" recordSetVar="CSparam" extensions="Ctrl"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}" "/> </apex:pageBlockButtons> <apex:pageBlockSection > <apex:pageBlockTable value="{!CSparam}" var="a" > <apex:column headerValue="Field 1 "> <apex:inputField value="{!a.Field1__c}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> //here I have other field of the custom setting </apex:pageBlock > </apex:form > </apex:page>
And for the save button I want to override it to redirect to another vf page:
public with sharing class Ctrl { public Ctrl (ApexPages.StandardSetController controller) { } public PageReference save() { csObject__c cs = csObject__c.getValues('param'); update cs; PageReference pageRef = new PageReference('/apex/VF'); return pageRef; } }
But it doesn't work I still have the old values of the cs fields...
If anyone could help me with this, it would be great...
Thanks!
What I would do is modify the vfp where your extension class becomes the controller:
Then in the controller class, get the CsObjectList that your table will use as data source and remove the getValues line from your save method. Now, you said that you want to modify only the csObject llamado "param", for that you will need to override the getall().values() with a SOQL With this your list of custom settings will have only one record.
Hope this helps you
All Answers
You can use the inline edit. Try the following snippet -
Apex Controller - VF - Hope, it will help you.
Thanks,
Sumit Kuamr Singh
What I would do is modify the vfp where your extension class becomes the controller:
Then in the controller class, get the CsObjectList that your table will use as data source and remove the getValues line from your save method. Now, you said that you want to modify only the csObject llamado "param", for that you will need to override the getall().values() with a SOQL With this your list of custom settings will have only one record.
Hope this helps you
Respect.
Please I have a problem, for example if i don't have this 'Param' record in cs I want that it will be created with the same name then edit the other fields, if it's already created we can modify directly its fields
Any help?
What you can do is verify the list size, if the list size is empty you can create a new cs named 'param'. You will also need to modify the update statement in your save method for upsert, with this you will insert or update the record..