Choice Labels and choice Values Error

I have created an expression rule, which retrieves all colors based on a "lot number".  The rule works fine.

But when I try to use the result on choiceLabels and choiceValues, it gives the error "The choiceLabels and choiceValues arrays must be the same length, but choiceLabels was length 2 and choiceValues was length 1". Both the choicelabel and choicevalue have been passed on the same rule. My database currently has 2 colors for lot number 1.

May I know what did I do wrong?

Code of choice label and choice value:

choiceLabels: rule!LN_Fetch_colors(local!lotId).data.colorsAvailable,
choiceValues: rule!LN_Fetch_colors(local!lotId).data.colorsAvailable,

This is the output of the rule:

This is my entry in database:

  Discussion posts and replies are publicly visible

Parents
  • Hello,

    As Natasha mentioned in another reply, it would be good to have the result of that rule in a local variable. Since you use it in two places, by referring to the local variable you would be calling the rule only once, instead of twice.

    As for the issue you're facing, since choiceLabels and choiceValues expect a list, try to have the expression you currently have between brackets:

    choiceLabels: {rule!LN_Fetch_colors(local!lotId).data.colorsAvailable},
    choiceValues: {rule!LN_Fetch_colors(local!lotId).data.colorsAvailable},

    It seems that in your case, the call performed by choiceValues is only retrieving the first value from the rule, not a list with the 2 results.

Reply
  • Hello,

    As Natasha mentioned in another reply, it would be good to have the result of that rule in a local variable. Since you use it in two places, by referring to the local variable you would be calling the rule only once, instead of twice.

    As for the issue you're facing, since choiceLabels and choiceValues expect a list, try to have the expression you currently have between brackets:

    choiceLabels: {rule!LN_Fetch_colors(local!lotId).data.colorsAvailable},
    choiceValues: {rule!LN_Fetch_colors(local!lotId).data.colorsAvailable},

    It seems that in your case, the call performed by choiceValues is only retrieving the first value from the rule, not a list with the 2 results.

Children
No Data