You need to sign in to do that
Don't have an account?
One Record Restriction
Hi
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.
Page:
Controller:
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=' + newSetting.id);
}
--------------------------------------------------------------------------------------------------------
I don't see why you aren't doing
<apex:page standardController="XML_Setting__c" extensions="SettingsController">