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
@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