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

One Record Restriction



I have a problem with page refreshing. I  want a configuration setting for the objects to update. I have created an object to maintain the record. I need only one record per user in that object.


For that I have written code in constructor so that each time a page is refreshing another record gets created.


Can any one of you modify my code and send back to me. I have to update only one record. No need of creating another record.






<apex:page controller="SettingsController">


 <apex:form id="form">  


        <apex:sectionHeader title="Object Settings" subtitle="Configure Settings">




                Settings that control the behavior of the Donor Management package. Changing these will change how your Package behaves.
        <apex:pageMessages id="pageMessages"/>
         <apex:pageBlock id="xmlsettings" title="XML Settings">
        <apex:pageBlockButtons >
             <apex:commandButton action="{!save}" Value="Update Settings"/>
          <apex:pageBlockSection title="Contacts" >
                  <apex:inputField value="{!newSetting.Contacts__c}"  onClick="hideAccount(this)" />
             <apex:pageBlockSection title="Accounts">
                 <apex:inputField value="{!newSetting.Accounts__c}" />
             <apex:pageBlockSection title="Opportunities">
                 <apex:inputField value="{!newSetting.Opportunities__c}"/>
             <apex:pageBlockSection title="Households">
                  <apex:inputField value="{!newSetting.Households__c}"/>
















public with sharing class SettingsController {

XML_Setting__c newSetting;


    public XML_Setting__c getnewSetting() {return newSetting;}

    public void setnewSetting(XML_Setting__c newSetting) {this.newSetting= newSetting; }

    public SettingsController() {

    Id id = ApexPages.currentPage().getParameters().get('id');

   newSetting = (id == null) ? new XML_Setting__c() : [Select Name,Contacts__c,Accounts__c,Opportunities__c,Households__c from XML_Setting__c where Id=:id ];




    public PageReference Save()







       upsert newSetting;

        return null;






I'm not sure I completely understand what you want.... but


public PageReference Save()


     upsert newSetting;


     return new PageReference('/apex/SettingsPage?id=' +;




I don't see why you aren't doing

<apex:page standardController="XML_Setting__c"  extensions="SettingsController">