Dropdown null value issue

Hi ,

 

I have an issue with dropdown. I want to display current year by default in my year dropdown.

For that i have appended year with the year dataset but its giving me error.

/*placeholderLabel: "--Select a Year-- ",*/ - In this by default current year should be display and selected.

 

Below code i have in load().

local!year1: append(tointeger(todatasubset(
    local!data,
    a!pagingInfo(
      startIndex: 1,
      batchSize: - 1,
      sort: a!sortInfo(
        field: "year",
        ascending: false
      )
    )
  ),year(today()))),
  local!year: if(
    rule!APN_isBlank(
      local!data
    ),
    {},
   union(
      index(
        local!year1.data,
        "year"
      ),
      index(
        local!year1.data,
        "year"
      )
      
    )
  ),

 

a!dropdownField(
label: "Year",
labelPosition: "ABOVE",
/*placeholderLabel: "--Select a Year-- ",*/
choiceLabels: local!Year,
choiceValues: local!Year,
value: local!selectedYear,
saveInto: { local!selectedCycleYear }
)

 

But i am getting error. Could not display interface. Please check definition and inputs.
Interface Definition: Expression evaluation error at function a!dropdownField [line 190]: A dropdown component [label=Year”] has an invalid value for “value”. Value cannot be null.

 

If i un comment this section - /*placeholderLabel: "--Select a Year-- ",*/ 

than its working fine but as per my requirement i don't want to display this text , dropdown should populate with year data along with current year on top of that(In selected mode)

 

What could be the workaround of this problem.

  Discussion posts and replies are publicly visible

Parents
  • I tried to put null check also before this dropdown but after that its not showing this dropdown in case of local!selectedCycleYear null check and when i tried with local!year null than nothing is getting impact same error is coming.
  • 0
    A Score Level 1
    in reply to sauravk
    Hi Saurav,

    local!Year is list of years which contain current year (which you wan to be selected when form is loaded) right? If yes then did you try assigning the local!selectedYear=current year (which you wan to be selected when form is loaded) ?
  • can you share one liner code or modify this code as per your approach if possible
  • if(isnull(local!selectedYear),{},dropdown()) here i have assigned current year to selectedYear but its completing hiding that dropdown.
  • @sauravk: Can you please try below code snippet.

     

     

    load(
    local!data:{
    {id:1,name:"user1",year:2016},
    {id:2,name:"user2",year:2017}
    },
    local!selectedYear:year(
    today()
    ),
    local!selectedCycleYear,
    local!dataSubset:todatasubset(
    local!data,
    a!pagingInfo(
    startIndex: 1,
    batchSize: - 1,
    sort: a!sortInfo(
    field: "year",
    ascending: false
    )
    )
    ),
    local!year: if(
    rule!APN_isBlank(
    local!data
    ),
    {},
    rule!APN_distinct(append(
    tointeger(
    index(
    local!dataSubset.data,"year",null),
    local!selectedYear
    )
    ))
    ),
    a!formLayout(
    contents: {
    a!dropdownField(
    label: "Year",
    labelPosition: "ABOVE",
    /*placeholderLabel: "--Select a Year-- ",*/
    choiceLabels: local!Year,
    choiceValues: local!Year,
    value: local!selectedYear,
    saveInto: {
    local!selectedCycleYear
    }
    )
    }
    )
    )

  • load(
      local!data: {
        {
          id: 1,
          name: "user1",
          year: 2016
        },
        {
          id: 2,
          name: "user2",
          year: 2017
        }
      },
      local!selectedYear: year(
        today()
      ),
      local!selectedCycleYear,
      local!dataSubset: todatasubset(
        local!data,
        a!pagingInfo(
          startIndex: 1,
          batchSize: - 1,
          sort: a!sortInfo(
            field: "year",
            ascending: false
          )
        )
      ),
      local!year: if(
        rule!APN_isBlank(
          local!data
        ),
        {},
        rule!APN_distinct(
          append(
            tointeger(
              index(
                local!dataSubset.data,
                "year",
                null
              ),
              local!selectedYear
            )
          )
        )
      ),
      a!formLayout(
        contents: {
          a!dropdownField(
            label: "Year",
            labelPosition: "ABOVE",
            /*placeholderLabel: "--Select a Year-- ",*/
            choiceLabels: local!Year,
            choiceValues: local!Year,
            value: local!selectedYear,
            saveInto: {
              local!selectedCycleYear
            }
          ),
          a!textField(local!selectedCycleYear)
        }
      )
    )

    I got one issue in this code. local!selectedCycleYear value is not saving for 2018 for rest year it is getting save.
    Plz add this a!textField(local!selectedCycleYear) n you will see result.

  • Can you have look now.

    load(
      
      local!data: {
        {
          id: 1,
          name: "user1",
          year: 2016
        },
        {
          id: 2,
          name: "user2",
          year: 2017
        }
      },
      /*local!selectedYear: year(
        today()
      ),*/
      local!selectedCycleYear: year(
        today()
      ),
      local!dataSubset: todatasubset(
        local!data,
        a!pagingInfo(
          startIndex: 1,
          batchSize: - 1,
          sort: a!sortInfo(
            field: "year",
            ascending: false
          )
        )
      ),
      local!year: if(
        rule!APN_isBlank(
          local!data
        ),
        {
          local!selectedCycleYear
        },
        rule!APN_distinct(
          append(
            tointeger(
              index(
                local!dataSubset.data,
                "year",
                null
              ),
              local!selectedCycleYear
            )
          )
        )
      ),
      a!formLayout(
        contents: {
          a!dropdownField(
            label: "Year",
            labelPosition: "ABOVE",
            /*placeholderLabel: "--Select a Year-- ",*/
            choiceLabels: local!Year,
            choiceValues: local!Year,
            value: local!selectedCycleYear,
            saveInto: {
              local!selectedCycleYear
            }
          ),
          a!textField(label:"Debug local!selectedCycleYear",value:local!selectedCycleYear,readOnly: true())
        }
      )
    )

    What is Diff b/w local!selectedYearand local!selectedCycleYear , If above code is fine Just remove unnecessary local variables

  • Plz find updated code.

    load(

    local!data: {
    {
    id: 1,
    name: "user1",
    year: 2016
    },
    {
    id: 2,
    name: "user2",
    year: 2017
    }
    },
    /*local!selectedYear: year(
    today()
    ),*/
    local!selectedCycleYear: year(
    today()
    ),
    local!dataSubset: todatasubset(
    local!data,
    a!pagingInfo(
    startIndex: 1,
    batchSize: - 1,
    sort: a!sortInfo(
    field: "year",
    ascending: false
    )
    )
    ),
    local!year: if(
    rule!APN_isBlank(
    local!data
    ),
    {
    local!selectedCycleYear
    },
    rule!APN_distinct(
    append(
    tointeger(
    index(
    local!dataSubset.data,
    "year",
    null
    ),
    local!selectedCycleYear
    )
    )
    )
    ),
    a!formLayout(
    contents: {
    a!dropdownField(
    label: "Year",
    labelPosition: "ABOVE",
    /*placeholderLabel: "--Select a Year-- ",*/
    choiceLabels: local!Year,
    choiceValues: local!Year,
    value: local!selectedCycleYear,
    saveInto: {
    local!selectedCycleYear,
    a!save(ri!year,local!selectedCycleYear)
    }
    ),
    a!textField(label:"Debug local!selectedCycleYear",value:ri!year,readOnly: true())
    }
    )
    )

    Have a look its not able to assign value in rule input variable. Sorry i forgot to add this in previous chat. I was about to ask this only. By mistake add wrong variable name.
  • : Above code is working fine for me, What issue you are facing?
  • I am trying to pass default selected value of drop down to rule input variable and further passing that variable to Process Modal. That ri!Variable is getting save on event basis in drop down. So if i don't change anything in drop down and click on submit button that there would be nothing save in the ri!Variable. That's why ri!year is not displaying anything by default. But default selectedCycleYear value should be also save to this variable which is the problem here.
  • Please find below .

    Work Around-1:

    On click of Submit Button just check the below condition.

    if(
    rule!APN_isEmpty(ri!year),
    a!save(ri!year,local!selectedCycleYear),
    null
    ),

    Work Around-2:

    Pass ri!year value from Process Model it self[Before Attended node , Take the Current year], In this case no need to write extra code SAIL level.

    Thanks!!

Reply Children