I have a dropdown list.If no selection is made, the system saves a null value in

I have a dropdown list.If no selection is made, the system saves a null value into the component's Save Selection To field.Confused by this Error - "A dropdown component [label=“Company”] has an invalid value for “value”. All selected values must be present in the choiceValues array, but value was and choiceValues was ABI2WG ; ACC1LON ; ACEI4BRI; ACI2SYD ; ".
Expression Error : "Expression evaluation error in rule 'vc_mc_brokercontactdetail' (called by rule 'vc_mc_managecontacts'): A null parameter has been passed."
Below is the code which renders it
a!dropdownField(
label: cons!VC_LB_COMPANY,
labelPosition: cons!VC_LB_POSITION_ADJACENT,

choiceLabels: {
apply(fn!tostring,local!brokerCompany.id)
},
choiceValues: {
apply(fn!tostring,local!brokerCompany.id)
},
placeholderLabel: cons!VC_CMS_LB_PLACEHOLDER_SELECT...

OriginalPostID-150440

OriginalPostID-150440

  Discussion posts and replies are publicly visible

  • ...,
    value: local!broker.customer_Code,
    saveInto: local!broker.customer_Code
    )
    )
    Any thoughts on why this could happen ? - unable to debug this
  • @revathis Hi, here goes few suggestions to resolve the issue:

    1. Configure the value attribute as
    value: if(rule!APN_isEmpty(local!broker),null,local!broker.customer_Code)
    or
    value: index(local!broker,"customer_Code",null)

    2. Additionally ensure that the value present in local!broker.customer_Code is one among the values of local!brokerCompany.id

    I guess the above two should resolve the issue.

    Note: If you haven't made a search in the forum already, please go through /search?q=OriginalPostID-145508.
  • +1
    Certified Senior Developer

    Hi, I just had the same issue, I had to encapsulate the value in a 'tostring' so that the types matched.

    So value: tostring(local!broker.customer_Code)

     

    a!dropdownField(
    label: cons!VC_LB_COMPANY,
    labelPosition: cons!VC_LB_POSITION_ADJACENT,

    choiceLabels: {
    apply(fn!tostring,local!brokerCompany.id)
    },
    choiceValues: {
    apply(fn!tostring,local!brokerCompany.id)
    },
    placeholderLabel: cons!VC_CMS_LB_PLACEHOLDER_SELECT,

    value: tostring(local!broker.customer_Code),
    saveInto: local!broker.customer_Code
    )