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
metaforcemetaforce 

Custom VF SelectList component error - "Validation Error: Value is not valid"

Hello. I have a custom VF component which contains an <apex:selectList> component, as follows:

 

<apex:component controller="picklistController" id="compPickList">
<apex:attribute name="SystemEntity" description="" type="String" required="true" default="Account" assignTo="{!systemObject}"></apex:attribute>
<apex:attribute name="picklistField" description="" type="String" required="true" default="Type" assignTo="{!picklist_Field}"></apex:attribute>
<apex:attribute name="value" description="" type="String[]" required="true"></apex:attribute>
<apex:selectList id="ddlPickList" value="{!value}" multiselect="true" size="4">
<apex:selectOptions value="{!pickListOptions}"></apex:selectOptions>
</apex:selectList>
</apex:component>

 

The component's controller is obvious, so am skipping it for now.

 

The component acceps two attributes which it uses to populate the selectList options. I am using this component in a page and it works fine, i.e. am able to retrieve the selected values from the component into the page as long as am working with the pre-populated options, the code is as follows:

 

 

<apex:page controller="sampleCon" id="myPage"> <apex:form id="myForm"> <c:sObjectFieldPicklistComponent id="accountPicklist" value="{!accountIndustry}" picklistField="Ownership" systemEntity="Account" /> <apex:commandButton value="Test" action="{!SaveValues}" /> </apex:form> </apex:page>

 

I am again skipping the page controller code as it's obvious, but do let me know if you want to see it.

 

Now, the problem starts when I add dynamic <option> to this multi-select picklist through JavaScript, am able to add them in the browser on the client side, but when I click on the command button to submit the user selected values, the previously working code breaks, the values are not submitted, the execution never enters the action function (in this case - SaveValues()), and I get a message in the System Log window:

 

myPage:myForm:accountPicklist:compPickList:ddlPickList: Validation Error: Value is not valid

 

Any idea what's happening here? I am suspecting that the system (not me) is checking the submitted values against the viewstate and is throwing an error somewhere which I am unable to trap and trace.

 

Can someone please explain this behavior, and if possible, a solution to get this thing going?

 

Thanks in advance!

Ajay

Best Answer chosen by Admin (Salesforce Developers) 
SDev5SDev5

I was able to find a workaround for this issue.

In my case I am using 3 tabs and 2 picklists are used for each tab. So for 3 tabs there are total of 6 picklists.

The issue was values for each pair of picklists were different for each tab. And due to values mismatch it was giving error on tab switch.

So the workaround that I found for this issue is :

I wrote small javascript code that is being called on tab change. Following is the javascript code I used. This refers the picklist and sets its value to  empty string :

document.getElementById ('page: myform1:block2:Info1: firstTable: 0:select1').value = ''; document.getElementById ('page: myform2:block2:Info2: secondTable: 1:select2').value = '';

 

This code just sets the value for each picklist to '  '(Empty String) temporarily. This is the default value for each picklist. So, when the page get loads completely original values overrides this default value and you get the value expected.

This way it does not give any validation error as default value is present in each picklist for each tab.   

All Answers

angusgrantangusgrant

Hi I have a simlar issue if I understand you correctly? When using the apex:SelectList tag my required fields are not displaying with the normal red left border property "showing that they are required" and when i try and submit  without populating the field I get the following or similar unreadble validation error message returned to to the . "j_id0:StdOXCEITemplate:j_id9:j_id37:j_id49:j_id50:org: Validation Error: Value is required." Returned to the apex:pageMessages tag.

 

Any solution appreciated   

DrawloopSupportDrawloopSupport
I am also having a similar issue on a selectRadio. I do not have it set as required nor have I set any other validation on the page.
jochen5478jochen5478

Did you decalere any varibles as static in your controller? If so try to remove the static keyword!

 

I had a similar problem and it was because I have set some relevat variables as static variables.

 

greetings

Jochen 

DrawloopSupportDrawloopSupport
I think the issue I had was with a set of checkboxes. The variable that stored the value for the checkboxes (public string[] selectedBoxes { get; set; }) was not set (selectBoxes = new string[]()) before the checked box's value was attempted to be added to the string[]. After making sure that the variable was set before values were added, the problem did not occur.
DrawloopSupportDrawloopSupport

Ajay (metaforce),

 

It looks like your variable accountIndustry should be an array since your selectList has multiselect="true". Can you check to see that you are setting accountIndustry ( = new List<string>();) before you click the commandButton?

 

Hope that helps.

 

MukulMukul

I have exactly the same issue. Can anyone help me out?

 

Regards

Mukul

DrawloopSupportDrawloopSupport

Mukul,

Can you post some sample code?

Thanks. 

MukulMukul

Thanks Drawloop Support, for the reply.

 

Here is my VF Code:

 

<apex:outputPanel id="scoreSetting" layout="block" style="{!showBlock}"> <apex:pageBlockSection title="Define Pick-List Mapping Rules (Select Ranges to Define the Score Values)" collapsible="false"> <apex:dataTable value="{!tempRules}" var="mr1" styleClass="tableClass list" rowClasses="odd,even"> <apex:column > <apex:facet name="header">Score</apex:facet> <apex:outputText value="Score"/> </apex:column> <apex:column > <apex:facet name="header">Operator</apex:facet> <apex:inputField value="{!mr1.mappingRule.ScoreOperator1__c}"/> </apex:column> <apex:column > <apex:facet name="header">Score Value 1</apex:facet> <apex:inputText value="{!mr1.MappingRule.ScoreVal1__c}" size="10"/> </apex:column> <apex:column > <apex:facet name="header">Operator</apex:facet> <apex:inputField value="{!mr1.MappingRule.ScoreOperator2__c}"/> </apex:column> <apex:column > <apex:facet name="header">Score Value 2</apex:facet> <apex:inputText value="{!mr1.MappingRule.ScoreVal2__c}" size="10"/> </apex:column> <apex:column > <apex:facet name="header">Mapping</apex:facet> <apex:selectList id="cbxlevel2" multiselect="false" value="{!mr1.selectedVal2}" size="1"> <apex:selectOptions value="{!pickListOptions}"></apex:selectOptions> </apex:selectList> </apex:column> </apex:dataTable> </apex:pageBlockSection> </apex:outputPanel> <apex:pageBlockButtons location="bottom"> <apex:commandButton action="{!saveAndDefine}" value="Save & Define Rules" id="defineRules"/> <apex:commandButton action="{!saveAndReturn}" value="Save & Return" id="return"/>

 

Here is my Controller Code:

 

// Get Map Rules List public List<tempList> tL = new List<tempList>(); public List<tempList> getTempRules() { String op = ApexPages.currentPage().getParameters().get('op'); // Mapping Rule for new rule Set if (op!= 'edit') { if (tL.size() < 10) { for (integer i = 0; i < 10; i++) { MappingRule__c MappingRule1 = new MappingRule__c(); System.debug('Temp List : ' + tL); tL.add( new tempList(MappingRule1, selectedVal2) ); } } } // Mapping Rule for existing rule set else { List <MappingRule__c> MappingRule1 = [select ScoreVal2__c, ScoreVal1__c, ScoreOperator2__c, ScoreOperator1__c, Mapping_Field__c, mapping__c From mappingRule__c where RuleSetId__c =: String.escapeSingleQuotes(getRuleSetId())]; Integer n = 10-MappingRule1.size(); if (tL.size() < 10) { for (MappingRule__c m : MappingRule1) { tL.add( new tempList(m, String.valueOf(m.mapping__c))); } for (integer i = 0; i < n; i++){ mappingRule__c mr = new mappingRule__c(); tL.add( new tempList(mr, selectedVal2)); } } System.debug('TL In EDIT: ' + tL); } return tL; } public void setTempRules(List<tempList> tL) { this.tL = tL; } public class tempList { public MappingRule__c mappingRule {get; set;} public String selectedVal2 {get; set;} public tempList(MappingRule__c mr, String sVal) { mappingRule = mr; selectedVal2 = sVal; } }

 

 

 

 

 

MukulMukul

I am sorry I didnt post the whole VF Page code. Here it is:

 

 

<apex:page controller="newScoreRuleController" tabStyle="Scoring_Rule_Wizard__tab"> <apex:sectionHeader title="{!text} Lead Target Rule Set" help="/apex/scoringRuleAppHelp"/> <apex:form id="theForm"> <apex:pageBlock title="Rule Set"> <apex:messages styleClass="error" /> <apex:pageBlockSection > <apex:pageBlockSectionItem > <apex:outputLabel value="Rule Set Name:" for="ruleSetName"/> <apex:inputText value="{!RuleSetName1}" id="ruleSetName"> </apex:inputText> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Comment:" for="ruleSetComment"/> <apex:inputText value="{!ruleSetComment1}" id="ruleSetComment"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <font color="red">Note: After calculating the score, the score will be stored in your lead record in which you map it to. Please pick it wisely. Mapping field can either be numeric or a picklist. A good example of mapping field will be Lead Rating.<br/></font> </apex:pageBlockSectionItem> <br/> <apex:pageBlockSectionItem id="mappingFld1"> <apex:outputLabel value="Mapping field:" for="mappingFld"/> <apex:selectList id="mappingFld" multiselect="false" value="{!mappingFld}" size="1"> <apex:actionSupport event="onchange" rerender="scoreSetting"/> <apex:selectOptions value="{!mapLeadFields}"></apex:selectOptions> <script type="text/javascript"> function leadChosen() { var selectedVal = document.getElementById('{!$Component.mappingFld}').value; // alert(selectedVal); // Cut the String and see what is the type... var temp = new Array(); temp = selectedVal.split('/'); var mytype = temp[0]; if (mytype == 'INTEGER' || mytype == 'DOUBLE' || mytype == 'CURRENCY' || mytype == '') { document.getElementById('{!$Component.scoreSetting}').style.display="none"; } else { document.getElementById('{!$Component.scoreSetting}').style.display="block"; } } window.onload = leadChosen; </script> <div class="mouseOverInfoOuter" onfocus="addMouseOver(this)" onmouseover="addMouseOver(this)"><img src="/s.gif" alt="" class="infoIcon" title=""/><div class="mouseOverInfo" style="display: none; opacity: 0;">Choose a field where you would want to store your final score for each lead. Your lead record will be updated with the value that you choose here.</div></div> </apex:selectList> </apex:pageBlockSectionItem> <br/> </apex:pageBlockSection> <apex:outputPanel id="scoreSetting" layout="block" style="{!showBlock}"> <apex:pageBlockSection title="Define Pick-List Mapping Rules (Select Ranges to Define the Score Values)" collapsible="false"> <apex:dataTable value="{!tempRules}" var="mr1" styleClass="tableClass list" rowClasses="odd,even"> <apex:column > <apex:facet name="header">Score</apex:facet> <apex:outputText value="Score"/> </apex:column> <apex:column > <apex:facet name="header">Operator</apex:facet> <apex:inputField value="{!mr1.mappingRule.ScoreOperator1__c}"/> </apex:column> <apex:column > <apex:facet name="header">Score Value 1</apex:facet> <apex:inputText value="{!mr1.MappingRule.ScoreVal1__c}" size="10"/> </apex:column> <apex:column > <apex:facet name="header">Operator</apex:facet> <apex:inputField value="{!mr1.MappingRule.ScoreOperator2__c}"/> </apex:column> <apex:column > <apex:facet name="header">Score Value 2</apex:facet> <apex:inputText value="{!mr1.MappingRule.ScoreVal2__c}" size="10"/> </apex:column> <apex:column > <apex:facet name="header">Mapping</apex:facet> <apex:selectList id="cbxlevel2" multiselect="false" value="{!mr1.selectedVal2}" size="1"> <apex:selectOptions value="{!pickListOptions}"></apex:selectOptions> </apex:selectList> </apex:column> </apex:dataTable> </apex:pageBlockSection> </apex:outputPanel> <apex:pageBlockButtons location="bottom"> <apex:commandButton action="{!saveAndDefine}" value="Save & Define Rules" id="defineRules"/> <apex:commandButton action="{!saveAndReturn}" value="Save & Return" id="return"/> <apex:commandButton action="/apex/ruleSet" value="Cancel" id="cancel"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

DrawloopSupportDrawloopSupport

Makul,

Is this your entire apex class? What action (clicking a button, changing a value, etc.) on the visualforce page causes the error?

Thanks. 

MukulMukul

Hi there,

 

No this is not my entire apex class. When i click the submit button, at that time it happens.

 

Regards

Mukul

DrawloopSupportDrawloopSupport

Makul,

Your visualforce page does not have a Submit button. The buttons are Save & Define Rules, Save & Return, and Cancel. In order to debug what those buttons are doing, I would need to be able to see the part of your class that includes the functions for those buttons. 

Thanks. 

MukulMukul

Hi Drawloop,

 

It happens the moment i click the Save and Define or Save and Return button. 

 

Here is my code:

 

 

/ Save and Define Method (This saves a rule set in the rule set object) public PageReference saveanddefine() { System.debug('In Save and Define...'); // Add it in a try catch loop so that it catches exceptions // try { // Insert it into the table and redirect it with the ID of the record System.debug('BEFORE******RULESETNAME' + RuleSetName1); String myId; // If a double field is chosen, blank out the tL String[] multVal = mappingFld.split('/'); if(multVal[0] == 'Double' || multVal[0] == 'Integer') { tL.clear(); } if(tL.size() > 0) { for (TempList m : tL) { System.debug('HERE in MappingRule'); System.debug('Score Val1: ' + m.mappingRule.ScoreVal1__c); System.debug('ScoreOp1: ' + m.mappingRule.ScoreOperator1__c); System.debug('ScoreOp2: ' + m.mappingRule.ScoreOperator2__c); System.debug('ScoreVal2: ' + m.mappingRule.ScoreVal2__c); System.debug('Mapping: ' + m.selectedVal2); if(m.mappingRule.ScoreVal1__c == '' && m.mappingRule.ScoreOperator1__c != null) { System.debug('HERE In ValidationRule'); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter a Score Value in the Score Value 1 column')); return null; } if(m.mappingRule.ScoreVal1__c != '' && m.mappingRule.ScoreOperator1__c != null && m.selectedVal2 == null) { System.debug('HERE In ValidationRule'); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter a rating for the mapping rule')); return null; } if(m.mappingRule.ScoreVal2__c == '' && m.mappingRule.ScoreOperator2__c != null) { System.debug('HERE In ValidationRule'); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter a Score Value in the Score Value 2 column')); return null; } if (m.selectedVal2 != null) { if (m.mappingRule.ScoreOperator1__c == null && m.mappingRule.ScoreVal1__c != '') { System.debug('SR OP1::' + m.mappingRule.ScoreOperator1__c); System.debug('SR Val1::' + m.mappingRUle.ScoreVal1__c); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter an Operator value.')); return null; } } if (m.selectedVal2 != null) { if (m.mappingRule.ScoreOperator2__c == null && m.mappingRule.ScoreVal2__c != '') { System.debug('SR OP2::' + m.mappingRUle.ScoreOperator2__c); System.debug('SR Val2::' + m.mappingRUle.ScoreVal2__c); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter an Operator value.')); return null; } } } } // Check if it is an edit operation or not String op = Apexpages.currentPage().getParameters().get('op'); if (op == 'edit') { System.debug('RULESETNAME In EDIT: ' + RuleSetName1); System.debug('RULESETCOMMENT In EDIT: ' + RuleSetComment1); myId = Apexpages.currentPage().getParameters().get('id'); // Edit the RuleSet fields RuleSet__c editRuleSet = [select ruleSet__c, RuleSetComment__c, Mapping_Field__c from RuleSet__c where id =: myId]; editRuleSet.ruleSet__c = RuleSetName1; editRuleSet.ruleSetComment__c = RuleSetComment1; editRuleSet.Mapping_Field__c = MappingFld; update editRuleSet; // // Edit the Mapping Rule fields too List<MappingRule__c> editMapSet = [select Id, ScoreOperator1__c, ScoreOperator2__c, ScoreVal1__c, ScoreVal2__c, mapping__c from MappingRule__c where RuleSetId__c =: myId]; //System.debug('RULESET EDIT: ' + editMapSet); if (editMapSet.size() > 0) { delete editMapSet; } // system.debug('Mapping value : ' + getSelectedVal2()); // Take the tempList and start inserting values System.debug('TEMP LIST PRINT: ' + tL); // system.debug('Mapping value : ' + getSelectedVal2()); if(tL.size() > 0) { for(tempList r : tL){ MappingRule__c mapper = new MappingRule__c(); mapper.ruleSetId__c = myId; mapper.mapping__c = r.selectedVal2; mapper.ScoreOperator1__c = r.mappingRule.ScoreOperator1__c; mapper.ScoreOperator2__c = r.mappingRule.ScoreOperator2__c; mapper.ScoreVal1__c = r.mappingRule.ScoreVal1__c; mapper.ScoreVal2__c = r.mappingRule.ScoreVal2__c; mapper.Mapping__c = r.selectedVal2; mapper.Mapping_field__c = MappingFld; upsert mapper; } } // Delete the extra stuff that you got in here by adding empty lines List <mappingRule__c > maps = [Select Id From mappingRule__c n Where mapping__c = null ]; delete maps; } else { System.debug('RULESETNAME In NEW: ' + getRuleSetName1()); RuleSet__c newRuleSet = new RuleSet__c(RuleSet__c = RuleSetName1, RuleSetComment__c = getRuleSetComment1(), Mapping_Field__c = getMappingFld()); insert newRuleSet; // Get the ID of the record inserted and redirect String ruleName = ruleSetName1; RuleSet__c ruleId = [select id from RuleSet__c where ruleSet__c =: ruleName]; myId = String.valueOf(ruleId.id); System.debug('RULE ID' + myId); // system.debug('Mapping value : ' + getSelectedVal2()); if(tL.size() > 0) { for(tempList r : tL){ MappingRule__c mapper = new MappingRule__c(); mapper.ruleSetId__c = myId; mapper.mapping__c = r.selectedVal2; mapper.ScoreOperator1__c = r.mappingRule.ScoreOperator1__c; mapper.ScoreOperator2__c = r.mappingRule.ScoreOperator2__c; mapper.ScoreVal1__c = r.mappingRule.ScoreVal1__c; mapper.ScoreVal2__c = r.mappingRule.ScoreVal2__c; mapper.Mapping__c = r.selectedVal2; mapper.Mapping_field__c = MappingFld; upsert mapper; } } System.debug('TEMP LIST PRINT: ' + tL); // Delete the extra stuff that you got in here by adding empty lines List <mappingRule__c > maps = [Select Id From mappingRule__c Where mapping__c = null ]; delete maps; } // Create a new Page URL with the String ID appended to it PageReference pg = new PageReference('/apex/scoreRuleStep1?id=' + myId); pg.setRedirect(true); return pg; // } // catch (Exception ex) { // ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Query Error: ' + ex.getMessage())); // return null; // } } // Save and Return Method (for ruleset) public PageReference saveandreturn() { // Add it in a try catch loop so that it catches exceptions try { // Insert it into the table and redirect it with the ID of the record System.debug('BEFORE******RULESETNAME' + RuleSetName1); String myId; String[] multVal = mappingFld.split('/'); if(multVal[0] == 'Double' || multVal[0] == 'Integer') { tL.clear(); } if(tL.size() > 0) { // for (MappingRule__c m : mappingRule) { for (TempList m : tL) { System.debug('HERE in MappingRule'); System.debug('Score Val1: ' + m.mappingRule.ScoreVal1__c); System.debug('ScoreOp1: ' + m.mappingRule.ScoreOperator1__c); System.debug('ScoreOp2: ' + m.mappingRule.ScoreOperator2__c); System.debug('ScoreVal2: ' + m.mappingRule.ScoreVal2__c); System.debug('Mapping: ' + m.selectedVal2); if(m.mappingRule.ScoreVal1__c == '' && m.mappingRule.ScoreOperator1__c != null) { System.debug('HERE In ValidationRule'); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter a Score Value in the Score Value 1 column')); return null; } if(m.mappingRule.ScoreVal1__c != '' && m.mappingRule.ScoreOperator1__c != null && m.selectedVal2 == null) { System.debug('HERE In ValidationRule'); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter a rating for the mapping rule')); return null; } if(m.mappingRule.ScoreVal2__c == '' && m.mappingRule.ScoreOperator2__c != null) { System.debug('HERE In ValidationRule'); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter a Score Value in the Score Value 2 column')); return null; } if (m.selectedVal2 != null) { if (m.mappingRule.ScoreOperator1__c == null && m.mappingRule.ScoreVal1__c != '') { System.debug('SR OP1::' + m.mappingRule.ScoreOperator1__c); System.debug('SR Val1::' + m.mappingRUle.ScoreVal1__c); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter an Operator value.')); return null; } } if (m.selectedVal2 != null) { if (m.mappingRule.ScoreOperator2__c == null && m.mappingRule.ScoreVal2__c != '') { System.debug('SR OP2::' + m.mappingRUle.ScoreOperator2__c); System.debug('SR Val2::' + m.mappingRUle.ScoreVal2__c); ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Please enter an Operator value.')); return null; } } } } // Check if it is an edit operation or not String op = Apexpages.currentPage().getParameters().get('op'); if (op == 'edit') { System.debug('RULESETNAME In EDIT: ' + RuleSetName1); System.debug('RULESETCOMMENT In EDIT: ' + RuleSetComment1); myId = Apexpages.currentPage().getParameters().get('id'); // Edit the RuleSet fields RuleSet__c editRuleSet = [select ruleSet__c, RuleSetComment__c, Mapping_Field__c from RuleSet__c where id =: myId]; editRuleSet.ruleSet__c = RuleSetName1; editRuleSet.ruleSetComment__c = RuleSetComment1; editRuleSet.Mapping_Field__c = MappingFld; update editRuleSet; // // Edit the Mapping Rule fields too List<MappingRule__c> editMapSet = [select Id, ScoreOperator1__c, ScoreOperator2__c, ScoreVal1__c, ScoreVal2__c, mapping__c from MappingRule__c where RuleSetId__c =: myId]; //System.debug('RULESET EDIT: ' + editMapSet); if (editMapSet.size() > 0) { delete editMapSet; } // system.debug('Mapping value : ' + getSelectedVal2()); // Take the tempList and start inserting values System.debug('TEMP LIST PRINT: ' + tL); if(tL.size() > 0) { for(tempList r : tL){ MappingRule__c mapper = new MappingRule__c(); mapper.ruleSetId__c = myId; mapper.mapping__c = r.selectedVal2; mapper.ScoreOperator1__c = r.mappingRule.ScoreOperator1__c; mapper.ScoreOperator2__c = r.mappingRule.ScoreOperator2__c; mapper.ScoreVal1__c = r.mappingRule.ScoreVal1__c; mapper.ScoreVal2__c = r.mappingRule.ScoreVal2__c; mapper.Mapping__c = r.selectedVal2; mapper.Mapping_field__c = MappingFld; upsert mapper; } } // Delete the extra stuff that you got in here by adding empty lines List <mappingRule__c > maps = [Select Id From mappingRule__c n Where mapping__c = null ]; delete maps; } else { System.debug('RULESETNAME In NEW: ' + getRuleSetName1()); RuleSet__c newRuleSet = new RuleSet__c(RuleSet__c = RuleSetName1, RuleSetComment__c = getRuleSetComment1(), Mapping_Field__c = getMappingFld()); insert newRuleSet; // Get the ID of the record inserted and redirect String ruleName = getRuleSetName1(); RuleSet__c ruleId = [select id from RuleSet__c where ruleSet__c =: ruleName]; myId = String.valueOf(ruleId.id); System.debug('RULE ID' + myId); // system.debug('Mapping value : ' + getSelectedVal2()); if(tL.size() > 0) { for(tempList r : tL){ System.debug('TL1: ' + r.mappingRule.ScoreOperator1__c); System.debug('TL1: ' + r.mappingRule.ScoreOperator2__c); System.debug('TL1: ' + r.mappingRule.ScoreVal2__c); System.debug('TL1: ' + r.mappingRule.ScoreVal1__c); System.debug('TL1: ' + r.selectedVal2); MappingRule__c mapper = new MappingRule__c(); mapper.ruleSetId__c = myId; mapper.mapping__c = r.selectedVal2; mapper.ScoreOperator1__c = r.mappingRule.ScoreOperator1__c; mapper.ScoreOperator2__c = r.mappingRule.ScoreOperator2__c; mapper.ScoreVal1__c = r.mappingRule.ScoreVal1__c; mapper.ScoreVal2__c = r.mappingRule.ScoreVal2__c; mapper.Mapping__c = r.selectedVal2; mapper.Mapping_field__c = MappingFld; upsert mapper; } } System.debug('TEMP LIST PRINT: ' + tL); // Delete the extra stuff that you got in here by adding empty lines List <mappingRule__c > maps = [Select Id From mappingRule__c Where mapping__c = null ]; delete maps; } // Create a new Page URL with the String ID appended to it PageReference pg = new PageReference('/apex/ruleSet'); pg.setRedirect(true); return pg; } catch (Exception ex) { ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Query Error: ' + ex.getMessage())); return null; } }

 

Thanks again for all your help!

 

Regards

Mukul

 

 

MukulMukul

Hi Drawloop,

 

Were you able to find out what might be causing the issue? Please let me know.

 

it is very urgent!

 

Regards

Mukul

DrawloopSupportDrawloopSupport
Apologies, Makul. I have not had a chance to dig through all your code. If no one else here on the community boards can help quick enough, you can always log a ticket with Salesforce. They may or may not be able/willing to help, but it's worth a shot.
DrawloopSupportDrawloopSupport

Makul,

This still doesn't look like your entire apex class. I suspect the problem is with one of your get or set functions. I saw the error "Validation Error: Value is not valid" when a list was instantiated, not set to anything, and a value was being added to it. 

This error is exactly why we need Salesforce to implement this idea:  Visualforce Error Line Numbers.

Thanks. 

SDev5SDev5

I was able to find a workaround for this issue.

In my case I am using 3 tabs and 2 picklists are used for each tab. So for 3 tabs there are total of 6 picklists.

The issue was values for each pair of picklists were different for each tab. And due to values mismatch it was giving error on tab switch.

So the workaround that I found for this issue is :

I wrote small javascript code that is being called on tab change. Following is the javascript code I used. This refers the picklist and sets its value to  empty string :

document.getElementById ('page: myform1:block2:Info1: firstTable: 0:select1').value = ''; document.getElementById ('page: myform2:block2:Info2: secondTable: 1:select2').value = '';

 

This code just sets the value for each picklist to '  '(Empty String) temporarily. This is the default value for each picklist. So, when the page get loads completely original values overrides this default value and you get the value expected.

This way it does not give any validation error as default value is present in each picklist for each tab.   

This was selected as the best answer
SDev5SDev5

I was able to find a workaround for this issue.

In my case I am using 3 tabs and 2 picklists are used for each tab. So for 3 tabs there are total of 6 picklists.

The issue was values for each pair of picklists were different for each tab. And due to values mismatch it was giving error on tab switch.

So the workaround that I found for this issue is :

I wrote small javascript code that is being called on tab change. Following is the javascript code I used. This refers the picklist and sets its value to  empty string :

document.getElementById ('page: myform1:block2:Info1: firstTable: 0:select1').value = '';

document.getElementById ('page: myform2:block2:Info2: secondTable: 1:select2').value = '';

 

This code just sets the value for each picklist to '  '(Empty String) temporarily. This is the default value for each picklist. So, when the page get loads completely original values overrides this default value and you get the value expected.

This way it does not give any validation error as default value is present in each picklist for each tab.