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
MukulMukul 

How to prefill a form?

Hi all,

 

I have a visualforce page that i would like to prefill if the operation selected is Edit.

 

However i am facing this issue. If i prefill it, then i am unable to save the changes :

 

Here is the example:

<apex:page controller="newScoreRuleController" tabStyle="Scoring_Rule_Wizard__tab"> <apex:sectionHeader title="Create New Scoring Rule Set" help="/apex/scoringRuleAppHelp"/> <apex:form > <apex:pageBlock title="Rule Set" mode="edit"> <apex:messages styleClass="error" /> <apex:pageBlockSection > <apex:pageBlockSectionItem > <apex:outputLabel value="Rule Set Name:" for="ruleSetName"/> <apex:outputPanel layout="block" styleClass="requiredInput"> <apex:outputPanel layout="block" styleClass="requiredBlock"/> <apex:inputText value="{!RuleSetName1}" id="ruleSetName" required="true"/> </apex:outputPanel> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Rule Set Comment:" for="ruleSetComment"/> <apex:outputPanel layout="block" styleClass="requiredInput"> <apex:outputPanel layout="block" styleClass="requiredBlock"/> <apex:inputText value="{!ruleSetComment1}" id="ruleSetComment" required="true"/> </apex:outputPanel>

 Here is my Controller Code:

 

 

// Get me the Rule Set ID public String getRuleSetId() { String ruleId = ApexPages.currentPage().getParameters().get('id'); return ruleId; } public string getRuleSetName1() { String op = ApexPages.currentPage().getParameters().get('op'); if (op != 'edit') { } else { RuleSet__c ruleset = [select ruleSet__c from RuleSet__c where id =: getRuleSetId()]; String rulesetname = ruleset.RuleSet__c; this.RuleSetName1 = rulesetname; } return this.RuleSetName1; } public string getRuleSetComment1() { String op = ApexPages.currentPage().getParameters().get('op'); if (op != 'edit') { return this.RuleSetComment1; } else { RuleSet__c ruleset = [select ruleSetComment__c from RuleSet__c where id =: getRuleSetId()]; String rulesetcomment = ruleset.RuleSetComment__c; return rulesetcomment; } }

 

 

 

 Any help is much appreciated!!

 

 

 


 

Best Answer chosen by Admin (Salesforce Developers) 
MukulMukul

I fixed it by correcting my Set Method.

 

http://community.salesforce.com/sforce/board/message?message.uid=138435

 

Regards

Mukul