Editable Grid

Certified Associate Developer

I am getting  this error "Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 40]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!dropdownField [line 65]: A dropdown component [label="roleName1"] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was Role1 and choiceValues was Role1; Role2.".Could anyone please help me to resolve this error

a!localVariables(
local!jurisdictionTask:{
a!map(id:1,taskName:"Task1",taskDescription:"Upload Document1",jurisdictionName:"Arizona",roleName:"Role1",applicationType:"Application Type1" ),
a!map(id:2,taskName:"Task2",taskDescription:"Upload Document2",jurisdictionName:"Arizona",roleName:"Role1",applicationType:"Application Type1"),
a!map(id:3,taskName:"Task3",taskDescription:"Upload Document3",jurisdictionName:"Arizona",roleName:"Role1",applicationType:"Application Type1"),
},

a!headerContentLayout(
contents: {
a!cardLayout(
contents:
a!gridLayout(
label: "Tasks List",
instructions: "",
headerCells: {
a!gridLayoutHeaderCell(label: "Task Name"),/*open text*/
a!gridLayoutHeaderCell(label: "Task Description"),/*open text*/
a!gridLayoutHeaderCell(label: "Jurisdiction"),
a!gridLayoutHeaderCell(label: "Role" ),
a!gridLayoutHeaderCell(label: "Application Type")
},
columnConfigs: {
a!gridLayoutColumnConfig(
width: "DISTRIBUTE"
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE"
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE"
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE"
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE"
)
},
rows: {
a!forEach(
items:local!jurisdictionTask,
expression:a!gridRowLayout(

contents: {

a!textField(
label:"taskName " & fv!index,
value:fv!item.taskName,
saveInto: fv!item.taskName
),
a!textField(
label:"taskDescription" & fv!index,
value:fv!item.taskDescription,
saveInto: fv!item.taskDescription
),
a!dropdownField(
label:"jurisdictionName" & fv!index,
choiceLabels: {"Arizona","Kansas"},
choiceValues: {"Arizona","Kansas"},
placeholder: "--- Select a jurisdiction ---",
value:fv!item.jurisdictionName,
saveInto:fv!item.jurisdictionName
),
a!dropdownField(
label:"roleName" & fv!index,
choiceLabels: {"Role1","Role2"},
choiceValues: {"Role1","Role2"},
placeholder: "--- Select a role ---",
value:fv!item.roleName,
saveInto: fv!item.roleName
),
a!dropdownField(
label:"applicationType" & fv!index,
choiceLabels: {"Application Type1","Application Type2"},
choiceValues: {"Application Type1","Application Type2"},
placeholder: "--- Select a application type ---",
value:fv!item.applicationType,
saveInto:fv!item.applicationType
)



},
id: fv!index,
)
)



},
selectionSaveInto: {},
addRowLink: a!dynamicLink(
label:"Add New Task",

saveInto: {
a!save(
local!jurisdictionTask, remove(local!jurisdictionTask, save!value)
),
}
),
shadeAlternateRows: true,
rowHeader: 1
))
},
backgroundColor: cons!NAIC_TXT_HEX_LIGHT_GREY,
contentsPadding: "EVEN_MORE"
)
)

  Discussion posts and replies are publicly visible

  • +1
    Certified Lead Developer

    Your code works for me. Did you try to reload the editor or click TEST? This refreshes any local variables you might have changed.

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    Hi ,On refresh it was not working for me,I replaced remove by append then it worked for me,But dont know what was happening earlier?

  • +1
    Certified Senior Developer

    hi   modified code you can try this

    a!localVariables(
      local!jurisdictionTask:{
        a!map(id:1,taskName:"Task1",taskDescription:"Upload Document1",jurisdictionName:"Arizona",roleName:"Role1",applicationType:"Application Type1" ),
        a!map(id:2,taskName:"Task2",taskDescription:"Upload Document2",jurisdictionName:"Arizona",roleName:"Role1",applicationType:"Application Type1"),
        a!map(id:3,taskName:"Task3",taskDescription:"Upload Document3",jurisdictionName:"Arizona",roleName:"Role1",applicationType:"Application Type1"),
      },
    
    
      a!headerContentLayout(
        contents: {
          a!cardLayout(
            contents:
            a!gridLayout(
              label: "Tasks List",
              instructions: "",
              headerCells: {
                a!gridLayoutHeaderCell(label: "Task Name"),/*open text*/
                a!gridLayoutHeaderCell(label: "Task Description"),/*open text*/
                a!gridLayoutHeaderCell(label: "Jurisdiction"),
                a!gridLayoutHeaderCell(label: "Role" ),
                a!gridLayoutHeaderCell(label: "Application Type"),
              
              },
              columnConfigs: {
                a!gridLayoutColumnConfig(
                  width: "DISTRIBUTE"
                ),
                a!gridLayoutColumnConfig(
                  width: "DISTRIBUTE"
                ),
                a!gridLayoutColumnConfig(
                  width: "DISTRIBUTE"
                ),
                a!gridLayoutColumnConfig(
                  width: "DISTRIBUTE"
                ),
                a!gridLayoutColumnConfig(
                  width: "DISTRIBUTE"
                ),
               
              },
              rows: {
                a!forEach(
                  items:local!jurisdictionTask,
                  expression:a!gridRowLayout(
    
                    contents: {
    
                      a!textField(
                        label:"taskName " & fv!index,
                        value:fv!item.taskName,
                        saveInto: fv!item.taskName
                      ),
                      a!textField(
                        label:"taskDescription" & fv!index,
                        value:fv!item.taskDescription,
                        saveInto: fv!item.taskDescription
                      ),
                      a!dropdownField(
                        label:"jurisdictionName" & fv!index,
                        choiceLabels: {"Arizona","Kansas"},
                        choiceValues: {"Arizona","Kansas"},
                        placeholder: "--- Select a jurisdiction ---",
                        value:fv!item.jurisdictionName,
                        saveInto:fv!item.jurisdictionName
                      ),
                      a!dropdownField(
                        label:"roleName" & fv!index,
                        choiceLabels: {"Role1","Role2"},
                        choiceValues: {"Role1","Role2"},
                        placeholder: "--- Select a role ---",
                        value:fv!item.roleName,
                        saveInto: fv!item.roleName
                      ),
                      a!dropdownField(
                        label:"applicationType" & fv!index,
                        choiceLabels: {"Application Type1","Application Type2"},
                        choiceValues: {"Application Type1","Application Type2"},
                        placeholder: "--- Select a application type ---",
                        value:fv!item.applicationType,
                        saveInto:fv!item.applicationType
                      ),
                    
    
    
    
                    },
                    id: fv!index,
                  )
                )
    
    
    
              },
              selectionSaveInto: {},
              addRowLink: a!dynamicLink(
                label:"Add New Task",
                 value: local!jurisdictionTask,
                saveInto: {
                  a!save(local!jurisdictionTask,append(local!jurisdictionTask,null)),
               
                  /*a!save(*/
                    /*local!jurisdictionTask, remove(local!jurisdictionTask, save!value)*/
                  /*),*/
                }
              ),
              shadeAlternateRows: true,
              rowHeader: 1
            ))
        },
        /*backgroundColor: cons!NAIC_TXT_HEX_LIGHT_GREY,*/
        contentsPadding: "EVEN_MORE"
      )
    )