Skip to main content
March 31, 2023
Question

Array of values in expression rule to be inserted in dropdown choice labels.

  • March 31, 2023
  • 9 replies
  • 0 views

I have an expression rule which is containing a data with multiple values, I am trying to insert that data to dropdown choice labels and choice values but I am not able to do that.Can anyone help me to configure that?

    9 replies

    harshitb6843
    March 31, 2023

    You can simply do that by using the append() function. If it doesn't work, please attach your code for better understanding of what you're doing wrong. 

    March 31, 2023

    Hi Harshit,

    thanks for your reply, getting this error

    code:

    a!localVariables(
    local!values:rule!MSAJ_getAllBrands(),
    local!saveValue,
    {
    a!sectionLayout(
    contents: {
    a!dropdownField(
    label: "Brand",
    labelPosition: "ABOVE",
    placeholder: "--- Select a Value ---",
    choiceLabels:append(local!values),
    choiceValues: append(local!values),
    value:local!saveValue,
    saveInto: local!saveValue,
    searchDisplay: "AUTO",
    validations: {}
    )
    }
    )
    })

    amans0009
    March 31, 2023

    choices values can not be null  , append function takes array and values as parameter and you are passing only array into this but this is not the error which is showing on screen, your local!values variable has a null value which should not be.

    and I think you do not have any use of append function , you can just simply pass the variable and it will be fine  until unless you have use for that .

    and try replacing line 2 with below piece of code

    reject(a!isNullOrEmpty,local!values:rule!MSAJ_getAllBrands()) // this will simply reject null values in an array

       

    mallepup3914
    March 31, 2023

    Hi @manik0004,

    You need to create expression rule to get the desired values list without using rule inputs first. Then, just call that expression rule in the choice values and labels. It'll work as you expected.

    March 31, 2023

    hi Prashanth,

    I am getting this error after calling that rule in choice labels and values