In the code below, I am not able to save the selected values. If i am selecting multiple values for a single question than I am getting below error-
"Interface Definition: Expression evaluation error at function a!forEach [line 19]: Error in a!forEach() expression during iteration 2: Expression evaluation error at function a!checkboxField [line 27]: Rule 'l' has 1 parameters, but instead passed 2 parameters."
I had highlighted the code where the code needs some correction. NOTE- This code worked perfectly fine for a!RadiobuttonField() but not able to save values while using a!CheckBoxField()
a!localVariables( local!question: /*calling QE rule to fetch the questions*/ local!option: /*calling QE rule to fetch the options*/ local!numberOfAnswers: 4, local!correctAnswer: /*calling QE rule to fetch the correct Answer*/ local!selectedAnswer: rule!MWJ_MultiCorrectOption_SelectedAnswer(), ///// this code is written below. ),
{ a!sectionLayout( label: "", contents: { a!forEach( items: local!question, expression: a!localVariables( local!currentQuestion: fv!index, { a!columnsLayout( columns: { a!columnLayout( contents: a!checkboxField( choiceLabels: { a!forEach( items: enumerate(local!numberOfAnswers), expression: index( split(stripwith(local!option, "[]ZYWX:"), ","), if( local!currentQuestion = 0, fv!index, fv!index + local!numberOfAnswers * (local!currentQuestion - 1) ) ) ) }, choiceValues: { a!forEach( items: enumerate(local!numberOfAnswers), expression: index( split(local!option, ","), if( local!currentQuestion = 0, fv!item, fv!index + local!numberOfAnswers * (local!currentQuestion - 1) ) ) ) }, label: fv!index & ". " & fv!item, labelPosition: "ABOVE", value: local!selectedAnswer.SelectedAnswer[local!currentQuestion], saveInto: a!save( local!selectedAnswer.SelectedAnswer[local!currentQuestion], save!value ), validations: {} ) ) }, alignVertical: "TOP" ),
------------------------------------------------------------------------------------
rule!MWJ_MultiCorrectOption_SelectedAnswer(),
a!localVariables( local!count:count(split(rule!MWJ_multiCorrect_fetchQuestion(),";")), local!selectedAnswer: a!forEach( items:enumerate(local!count), expression:
a!map( SelectedAnswer:null, DummyAnswer:null )), local!selectedAnswer,)
Discussion posts and replies are publicly visible
Yeah, well .... I agree, but when you say "not able to save the selected values", I think the issue is more with what happens AFTER the value is saved.
Yes, I had checked all the rules multiple times and able to fetch correct values from all the rules used in this code.
Is there anything needs to change in value or saveInto parameter?
I had used index() here & now am able to select multiple answers for a single question but if i select the answer for another question than the first selected answer gets vanished. Is there any way to resolve this and store all the selected values in local?
updated code-
value: index(local!selectedAnswer.SelectedAnswer,local!currentQuestion), saveInto: a!save( index(local!selectedAnswer.SelectedAnswer,local!currentQuestion), save!value ),
Firstly, the index function should have a third parameter which is the default value to return if the index isn't present. Secondly, when using list/array/dictionary/map in save into, avoid using index. You should only use it in the value parameter.
And now, try verifying that the variable you are trying to save in accepts multiple values, and try wrapping your save!value in a!flatten() function.
thanks for your response. could you suggest me how to fix this error.
Here I had selected 2 values and got this error.
Sorry, but this image doesn't load for me. Can you try uploading it again?
/resized-image/__size/640x480/__key/communityserver-discussions-components-files/13/8816.error1.png
It is clear. You have misconfigured a rule by passing in 2 parameters when it only accepts one. It is present on line 27.
Did you check the Rule - "I" at line 27 ?