Error getting saving a value of two fields.

Certified Senior Developer

Hello Folks,

Followed by above screenshots: I have two fields (dropdown and text). Text field comes up when click on plus icon. 

Scenario: Dropdown field contains company name. There is a possibility to add manual company name. That's why plus icon will be placed and on click of that shows up text field. I have column in a database called companyName that saves value.

Issue here is: Both field saves value into same "saveInto" which conflicts. When I fills up text field it shows dropdown error because value saves into same companyName column. Please see below code.

a!localVariables(
  local!company: false(),
  a!dropdownField(
    choiceLabels: local!CompanyLabels,
    choiceValues: local!CompanyLabels,
    label: "company name:",
    labelPosition: "ADJACENT",
    placeholder: "Select Choice",
    value: tostring(index(ri!company, "companyName", {})),
    saveInto: ri!company.companyName,
    disabled: if(
      toboolean(not(local!company)),
      false,
      true
    ),

  ),
  a!textField(
    label: "Manual company Name",
    value: ri!company,
    saveInto: {
      ri!company,
      a!save(ri!company.companyName, save!value)
    },
    labelPosition: "ADJACENT",
    showWhen: if(toboolean(local!company), true, false),

  )
)

  Discussion posts and replies are publicly visible

Parents Reply
  • +1
    Certified Lead Developer
    in reply to manjit.1486

    the only straightforward way for that is, if the user clicks the icon to switch back to the dropdown, have the saveInto for the icon click also clear out the user's manually entered value - since unless it EXACTLY matches on eof the dropdown's "choice values" list, it's expected that this error would occur.

    Secondarily, you could make the text field's save target something completely different (like a local variable) and move the entered value into the more "proper" location upon the form's "Submit button" click.

Children