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
  • As per the above details,

    1. There should be a primary key.
    2. You can have local!allColours variable which incle the rule which has been used in the choice values as well choice labels like
         local!allColorDetails:rule!LN_Fetch_colors(local!lotId).data

    3. In this way you will able to get all colours details will be collected in the local and then you can use particular local in choice values as well as choice      labels


    Please let me know if it helps you

  • Actually the shown table gets created automatically since a table named "lot" has a column with type text with multiple values. May I know how can I add a primary key to it?

    My problem got solved after I changed rule!LN_Fetch_colors(local!lotId).data.colorsAvailable to rule!LN_Fetch_colors(local!lotId).data.colorsAvailable[1].

    But why did choiceLabels got the correct length but choiceValues didn't?

  • 0
    Certified Senior Developer
    in reply to leeaan0001

    You are fetching out the data in the choice values and choice labels and you can see colorAvaliable_lotno is same for them due to which its throwing error

    For resolving it you can  include all colors in one local vaiable and that variable can be used for choice values and choice labels.

    According to it, it will provide us a one value rule!LN_Fetch_colors(local!lotId).data.colorsAvailable[1]. and this is not a best practice to use

Reply
  • 0
    Certified Senior Developer
    in reply to leeaan0001

    You are fetching out the data in the choice values and choice labels and you can see colorAvaliable_lotno is same for them due to which its throwing error

    For resolving it you can  include all colors in one local vaiable and that variable can be used for choice values and choice labels.

    According to it, it will provide us a one value rule!LN_Fetch_colors(local!lotId).data.colorsAvailable[1]. and this is not a best practice to use

Children