Skip to main content
December 8, 2021
Question

The value and selectedLabels lists must be the same length. pickerFieldCustom recursively calling to create multiple fields issue.

  • December 8, 2021
  • 7 replies
  • 0 views

So currently I have a forEach loop that calls a picker field, dropdown, and 3 button elements in a interface and it iterates over a dictionary of data passed through by a expression rule. I am getting the following error with the interface: 

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 237]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!forEach [line 245]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!pickerFieldCustom [line 263]: A custom picker component [label="Producing Country"] has an invalid value for "value". The value and selectedLabels lists must be the same length.

The code is as listed as follows:

countryProducerInterfaceLayout:

{
a!forEach(
    items: rule!countryProducerInterfaceFieldData(ri!map),
    expression:
    a!localVariables(
      local!items: fv!item,
      local!count: fv!item.count,
      a!cardLayout(
        contents: {
          a!forEach(
            items: enumerate(local!count),
            expression: 
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!localVariables(
                      local!prodCtryLabel: if(
                        or(
                          isnull(ri!map.dataProdCtry1),
                          length(ri!map.dataProdCtry1) < 1
                        ),
                        null,
                        rule!formatCountryName(
                          rule!queryCountryByGenc3(ri!map.dataProdCtry1)
                        )
                      ),
                      a!pickerFieldCustom(
                        label: local!items.label,
                        labelPosition: "ABOVE",
                        placeholder: "--- Search by Name or GENC 3 ---",
                        maxSelections: 1,
                        suggestFunction: rule!queryCountriesAutocomplete(_),
                        selectedLabels: if(isnull(ri!map.dataProdCtry1), local!prodCtryLabel, ri!map.dataProdCtry1),
                        value: if(
                          local!items.label = "Producing Country",
                          ri!map.pubProdCtry,
                          if(
                            local!items.label="Data Producing Country",
                            ri!map.dataProdCtry1,
                            null
                          ),
                        ),
                        saveInto: {
                          a!save(
                            ri!map.pubProdCtry,
                              if(
                                local!items.label = "Producing Country", 
                                save!value, null
                              )
                          ),
                          a!save(
                            ri!map.dataProdCtry1,
                            if(
                              local!items.label = "Data Producing Country", 
                              save!value, null
                            )
                          )
                        },
                        required: true
                      )
                    )
                  }
                ),
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: local!items.label2,
                      labelPosition: "ABOVE",
                      placeholder: "--- Select a Value ---",
                      choiceLabels: local!items.choiceLabels,
                      choiceValues: local!items.choiceValues,
                      value: if(
                        local!items.label = "Producing Country",
                        ri!map.pubProd,
                        if(
                          local!items.label="Data Producing Country",
                          ri!map.dataProd1,
                          null
                        ),
                      ),
                      saveInto: {
                        a!save(
                          ri!map.pubProd,
                          if(
                            local!items.label = "Producing Country", 
                            save!value, null
                          )
                        ),
                        a!save(
                          ri!map.dataProd1,
                          if(
                            local!items.label = "Data Producing Country", 
                            save!value, null
                          )
                        )
                      },
                      searchDisplay: "AUTO",
                      validations: {}
                    )
                  }
                ),
                a!columnLayout(
                  contents: {
                    a!checkboxField(
                      label: "Primary",
                      labelPosition: "ABOVE",
                      choiceLabels: {""},
                      choiceValues: {true},
                      value: {},
                      saveInto: {},
                      choiceLayout: "COMPACT",
                      choiceStyle: "STANDARD",
                      validations: {},
                      align: "CENTER"
                    )
                  },
                  width: "EXTRA_NARROW" 
                )
              }
            )
          ),
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!buttonArrayLayout(
                    buttons: {
                      a!buttonWidget(
                        label: "Remove",
                        icon: "minus",
                        value: local!count - 1,
                        saveInto: local!count,
                        size: "SMALL",
                        style: "LINK"
                      )
                    },
                    align: "END"
                  )
                },
                width: "AUTO"
              ),
              a!columnLayout(
                contents: {
                  a!buttonArrayLayout(
                    buttons: {
                      a!buttonWidget(
                        label: "Add",
                        icon: "plus",
                        value: local!count + 1,
                        saveInto: local!count,
                        size: "SMALL",
                        width: "MINIMIZE",
                        style: "LINK"
                      )
                    },
                    align: "END",
                    marginBelow: "STANDARD"
                  )
                },
                width: "EXTRA_NARROW"
              )
            }
          )
        },
        height: "AUTO",
        style: "NONE",
        marginBelow: "STANDARD"
        ),
      ),
  ),
}

countryProducerInterfaceFieldData:

data:{
    {
      /*Producing Country*/
      label: "Producing Country",
      
      /*Producing Organization*/
      label2: "Producing Organization",
      choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
      "Option 5", "Option 6", "Option 7", "Option 8",
      "Option 9", "Option 10", "Option 11", "Option 12"},
      choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
      
      /*Counts*/
      count: 1,
    },
    {
      /*Data Producing Country*/
      label: "Data Producing Country",
  
      /*Data Producing Organization*/
      label2: "Data Producing Organization",
      choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
      "Option 5", "Option 6", "Option 7", "Option 8",
      "Option 9", "Option 10", "Option 11", "Option 12"},
      choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},

      /*Counts*/
      count: 1,
      
      /*Primary*/
      primeValue: "blah",
      primeSaveInto: "blah"
      
    }
}

The formatCountryName and queryCountryByGenc3 is a name formatter and a query respectively. They are pulling from a record type as well. Let me know if you need anymore information I tried to give you everything I am working with.

7 replies

csteward
December 8, 2021

Hi Kyle, are you able to provide the value of ri!map?  

Otherwise I would suggest to add some debugging (text fields, etc) with the values of your picker's selectedLabels and value expressions, to see what values are being utilized - as the error indicates, the length of these values is different (for instance a null value but a selectedLabels length of 1).

andrewh0007
December 8, 2021

Hi Kyle,

As I don't have the ri!map values I'm a bit guessing but it could be the different between blank (or nothing) and null. An blank/empty variable isn't the same as a null variable. I'd try updating the local!prodCtryLabel at line 18 to be "{}" rather than "null" (specifically this would be line 23).

If this doesn't fix it then it would be extremely helpful to have one code block supplied that I can just copy and paste into a new interface object in order to play around with it myself.

kyleg0003Author
December 9, 2021

This didn't work. I dont know how I can supply one block of code for this, but I can try to get an example to recreate the problem.

The value of ri!map is a data type we have called maps this is just some fields that are located in here as well! 

csteward
December 9, 2021

The main point is we need some data to test with in this variable so that we can replicate and resolve the issue.  If you are able to share the data, you can comment out your picker (so the error subsides), place this paragraph field on your form and copy/paste the value into the thread here.

a!paragraphField(
  label: "DEBUG: ri!map",
  value: ri!map,
  readOnly: true
)