Friends,
My requirement is , A default value should be selected in the DD and the same should be stored in the Interface Input, during the page load. Later it needs to be updated as per user selection.
Drop Down List : Year Data will be listed on page load from an expression rule through an local variable (yearData)
SelectedYear: Is a Interface Input which will store the user selected values from the DD
I tried doing this by having a local variable, but it is not working. Please help with your suggestions.
local!selYear: if(isnull(ri!SelectedYear),local!yearData[1],ri!SelectedYear),
a!dropdownfield(
....
value: local!selYear
saveinto: a!save(ri!selectedFile,local!selYear)
)
Discussion posts and replies are publicly visible
Hi Sunil
You need to make the use of if - else conditional statements to achieve this requirement. And you cannot update the rule input unless user do not interact with the field which has saveInto rule input logic defined. Hence to handle such scenario we can make the use of Button Submit saveInto.
Hope below mention code snippet will help you to achieve your requirement.
load( local!years_int: {2016, 2017, 2018}, a!formLayout( label: "Demo", contents: { a!dropdownField( label: "Year", placeholderLabel: "-- Select --", choiceLabels: local!years_int, choiceValues: local!years_int, value: if( isnull(ri!selectedYear_int), index(local!years_int, 1, {}), /*Loading the first item from local variable as default*/ ri!selectedYear_int ), saveInto: ri!selectedYear_int ) }, buttons: a!buttonLayout( primaryButtons: a!buttonWidgetSubmit( label: "SUBMIT", style: "PRIMARY", saveInto: { if( isnull(ri!selectedYear_int), a!save(ri!selectedYear_int, index(local!years_int, 1, null())), /*Saving Default Item*/ {} ) } ) ) ) )