issue in dropdownFieldByIndex() when setting the value based on choiceLabels

Certified Associate Developer

My requirement is to display current month as default option in dropdown and user can change month value from dropdown if they want to change and for each month there should be integer value saved in Rule Input "selectedMonth", so I have applied dropdownFieldByIndex() function for this. If user select blank then it will revert it to current month but I am getting below issue:

SAIL Code:

local!currMonth: datetext(today(),"M"),
local!monthName: {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"},

a!dropdownFieldByIndex(
label: "",
labelPosition: "ABOVE",
placeholder: "--Select Month--",
choiceLabels:union(local!monthName,local!monthName),
/*choiceValues: tointeger(union(local!monthValue,local!monthValue)),*/
value: if(rule!APN_isNotBlank(ri!selectedMonth),ri!selectedMonth,local!currMonth),
saveInto:ri!selectedMonth,
searchDisplay: "ON"
)

Can anyone help with this what is the issue?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi Amrit,

    try to use the following: (it makes the code way more readable for other community members)



    1.) i dont see a reason for a union() at the choicelables ;)
    2.)I used a slightly different code and it was working pretty fine as i can tell. it just jumps back to "Nov". 

    a!localVariables(
      local!currMonth: datetext(today(),"M"),
      local!monthName: {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"},
      local!selectedMonth,
      a!dropdownFieldByIndex(
        label: "",
        labelPosition: "ABOVE",
        placeholder: "--Select Month--",
        choiceLabels:local!monthName,,
        /*choiceValues: tointeger(union(local!monthValue,local!monthValue)),*/
        value: if(not(isnull(local!selectedMonth)),local!selectedMonth,local!currMonth),
        saveInto:local!selectedMonth,
        searchDisplay: "ON"
      )
    )

    Did you use "0" (integer) as rule input value? 

Reply
  • 0
    Certified Senior Developer

    Hi Amrit,

    try to use the following: (it makes the code way more readable for other community members)



    1.) i dont see a reason for a union() at the choicelables ;)
    2.)I used a slightly different code and it was working pretty fine as i can tell. it just jumps back to "Nov". 

    a!localVariables(
      local!currMonth: datetext(today(),"M"),
      local!monthName: {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"},
      local!selectedMonth,
      a!dropdownFieldByIndex(
        label: "",
        labelPosition: "ABOVE",
        placeholder: "--Select Month--",
        choiceLabels:local!monthName,,
        /*choiceValues: tointeger(union(local!monthValue,local!monthValue)),*/
        value: if(not(isnull(local!selectedMonth)),local!selectedMonth,local!currMonth),
        saveInto:local!selectedMonth,
        searchDisplay: "ON"
      )
    )

    Did you use "0" (integer) as rule input value? 

Children
No Data