Dropdown field throwing an error as " Choice index 4 is out of bounds. The choice index must be between 1 and 3"

I am getting following error when i fetch some value of dropdown from database.....when  i mention "value" property of a!dropdownField following error get populated....

Interface Definition: Expression evaluation error at function a!forEach [line 46]: Error in a!forEach() expression during iteration 1 with identifier 1: Expression evaluation error at function a!dropdownField [line 70]: A dropdown component [label="option 1"] has an invalid value for "value". Choice index 4 is out of bounds. The choice index must be between 1 and 3

Here is my code(Options are coming from the Database):-


a!dropdownField(
label: "option " & fv!index,
placeholderLabel: "-- Select Answer -- ",
choiceLabels: fv!item.SetAnsCDT.Options,
choiceValues: fv!item.SetAnsCDT.Id,
value: fv!item.SetAnsCDT.Id,
saveInto: ri!setUpQueResponse.SetAnsId,
required: true
)

 

whole code is given below:-

 

load(
/*rule!DDG_getSetupQuestions()*/
local!ques: rule!DDG_getSetupQuestions(),
/*local!setUpResponse: rule!DDG_SetupQueResponseRule(),*/
/*local!answoption: rule!DDG_getSetQueAnsOption(6),*/
a!formLayout(
label: "SetUp Questions for " & ri!OppData.Opportunity_Id,
contents: {
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!boxLayout(
label: "Questions",
contents: {
a!gridLayout(
totalCount: count(
local!ques
),
headerCells: {
a!gridLayoutHeaderCell(
label: "Sr. No."
),
a!gridLayoutHeaderCell(
label: "Questions"
),
a!gridLayoutHeaderCell(
label: "Answer"
)/* For the "Remove" column a!gridLayoutHeaderCell(label: "" ) */

},
/* Only needed when some columns need to be narrow */
columnConfigs: {
a!gridLayoutColumnConfig(
width: "NARROW"
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: 3
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: 3
)
},
rows: a!forEach(
items: local!ques,
expression: a!gridRowLayout(
id: fv!index,
contents: {
/* For the Sr.NO Column*/
a!textField(
/* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
label: "Que " & fv!index,
value: fv!index,
saveInto: fv!index,
required: true,
readOnly: true
),
/* For the Question Text Column*/
/*fv!item.ID & "Q." & fv!index & " " & */
a!textField(
label: "QueText " & fv!index,
required: true,
value: fv!item.QuestionText,
saveInto: ri!setUpQueResponse.SetQuestId,
readOnly: true
),
/* For the Answer Option Column*/
a!dropdownField(
label: "option " & fv!index,
placeholderLabel: "-- Select Answer -- ",
choiceLabels: fv!item.SetAnsCDT.Options,
choiceValues: fv!item.SetAnsCDT.Id,
value: fv!item.SetAnsCDT.Id,
saveInto: ri!setUpQueResponse.SetAnsId,
required: true
)
}
)
),
addRowlink: a!dynamicLink(
/*label: "ADD",*/
value: {
startDate: today() + 1
},
saveInto: {
a!save(
ri!setUpQueResponse,
append(
ri!setUpQueResponse,
save!value
)
)
}
)
)
},
style: "#AED6F1",
marginBelow: "STANDARD"
)
}
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Submit",
submit: true,
style: "PRIMARY"
)
},
secondaryButtons: {
a!buttonWidget(
label: "Cancel",
value: true,
saveInto: ri!cancel,
submit: true,
style: "NORMAL",
validate: false
)
}
)
)
)

 

 

Please provide the solution....

  Discussion posts and replies are publicly visible