After experimenting with salesforce a bit i was trying to use Apex, and VisualForce to create a page. I wanted to make a simple form which would then save into one of my custom objects.

However I cannot achieve this. I have a custom setting, that i want to set. Using a form, and just save the setting. Something simple to start off to test complexity after. However after the save button is hit, i don't know how to save it.

Any help would be appreciated regarding this. Maybe some sample snippet, because the tutorials are sort of lousy in terms of custom fields.


2 Answers 2


Personally, I think custom settings arent as simple to start with when you could just use the standard objects. But I will give you an example with a custom object, which should work the same as your custom setting..in theory (what type of custom setting do you have? list or hierarchy? is it public or private?)

in your class:

public class myClass {
  //the object that will talk with the page
  public myCustomObj__c myObj {get; set;}

  public myClass() {
    //before we can use the object on the page we need to create an instance of it.
    myObj = new myCustomObj__c();

  public PageReference saveObject() {
    //on click of the button the page it will call this method
    //you could do some conditional stuff here or add a try/catch but here is the simple version
    insert myObj;

in your VF page:

<apex:page title="my form page" controller="myClass">
    <apex:outputlabel value="field 1" /><apex:outputfield value="{!myObj.field_1__c}" />
    <apex:outputlabel value="field 2" /><apex:outputfield value="{!myObj.field_2__c}" /> 
    <apex:commandButton value="Save" action="{!saveObject}" />

of corse this is VERY basic, ideally you would have the page re-render the status and of corse style the page as you like, but this shows how the page connects to the class and that the saveObject method takes what was entered in the form and saves the object by inserting it.

some links that may be useful: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_custom_settings.htm http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_customsettings.htm|StartTopic=Content%2Fapex_customsettings.htm|SkinName=webhelp

in general you will want to search most questions on http://www.developerforce.com/ and they will point to helpful guides :-) its how i learned..


I think , this link may be helpful for your question.


There is some typo on that link, i have submitted the error to Salesforce, hope they will update document soon.

It should be "public with sharing class RemoteObjectContactOverride" instead of "public class with sharing RemoteObjectContactOverride"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .