Load Default Values from Drop Down List to a Interface Input

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

Parents
  • Hi Sunil,

    If I understand your requirement correctly, this hsould work :

    local!year:{2018,2019,2020,2021},
    a!dropdownField(
    label:"Year",
    labelPosition:"ADJACENT",
    choiceLabels:local!year,
    choiceValues:local!year,
    value:if(isnull(ri!selectedYear),local!year[1],ri!selectedYear),
    saveInto:a!save(ri!selectedYear,save!value)
    )
  • 0
    Certified Lead Developer
    in reply to saksheer0001
    The one additional thing to note about saksheer's code here is what will happen if the user does NOT change the default value.

    Based on this code, ri!selectedYear would remain null, even though the default is selected on the drop down.

    I would recommend either...
    - also initializing ri!selectedYear to the default
    - or saving local!year[1] to ri!selectedYear ONLY IF ri!selectedYear is null (either on button submit or in the process model)
Reply
  • 0
    Certified Lead Developer
    in reply to saksheer0001
    The one additional thing to note about saksheer's code here is what will happen if the user does NOT change the default value.

    Based on this code, ri!selectedYear would remain null, even though the default is selected on the drop down.

    I would recommend either...
    - also initializing ri!selectedYear to the default
    - or saving local!year[1] to ri!selectedYear ONLY IF ri!selectedYear is null (either on button submit or in the process model)
Children