You need to sign in to do that
Don't have an account?
Issues on inserting a record in the object
Hi all,
I have a save method in my Controller. I want to save all fields in my object. I am able to save everthing except one. Everyother field is maintaining its state in the object's instance. All those are being saved properly.
I am passing one field through a parameter in URL. How can i save that field in my object?
Here is the snippet of my save method:
public With Sharing class newScoreRuleController { Lead lead; public List<ScoringRule__c> ScoringRule { get; private set;} public newScoreRuleController () { ScoringRule = new List<ScoringRule__c>(); ScoringRule.add( new ScoringRule__c() ); ScoringRule.add( new ScoringRule__c() ); ScoringRule.add( new ScoringRule__c() ); ScoringRule.add( new ScoringRule__c() ); ScoringRule.add( new ScoringRule__c() ); } public PageReference save() { scoringRule.fieldName__c = ApexPages.currentPage().getParameters().get('fld'); insert ScoringRule; return null; } }
Here is the snippet of my visualforce page:
<apex:pageBlockTable value="{!ScoringRule}" var="sr" id="theTable" rowClasses="odd,even" styleClass="tableClass" rows="5"> <apex:column > <apex:facet name="header">Field</apex:facet> <apex:facet name="footer"></apex:facet> <apex:outputText value="{!fieldName}"/> </apex:column> <apex:column width="25%"> <apex:facet name="header">Rule 1</apex:facet> <apex:inputField value="{!sr.ScoringRule_Rule1__c}"/> </apex:column> <apex:column width="25%"> <apex:facet name="header">Value 1</apex:facet> <apex:inputText value="{!sr.ScoringRule_Val1__c}"/> </apex:column> <apex:column width="25%"> <apex:facet name="header">Rule 2</apex:facet> <apex:inputField value="{!sr.Rule2__c}"/> </apex:column> <apex:column width="25%"> <apex:facet name="header">Value 2</apex:facet> <apex:inputField value="{!sr.Val2__c}"/> </apex:column> <apex:column width="25%"> <apex:facet name="header">Score</apex:facet> <apex:inputField value="{!sr.Score__c}"/> </apex:column> </apex:pageBlockTable>
Any help will be appreciated!! Thanks in advance!
Check this out.
for(ScoringRule__c s : scoringRule)
s.fieldName__c = ApexPages.currentPage().getParameters().get('fld');
insert scoringRule;
All Answers
Check this out.
for(ScoringRule__c s : scoringRule)
s.fieldName__c = ApexPages.currentPage().getParameters().get('fld');
insert scoringRule;