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
Yeah, well, that's expected. A dropdown can only show values from the choice values. Depending on what you want to achieve, you might want to consider just hiding the drop down when showing the text field.
I have tried this: hiding the dropdown field using showWhen attribute. It is hiding the dropdown and save textfield value.But when I click on icon to show dropdown field again: it gives me an error. How can I fix this issue?
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.
When you use same variable for both dropdown and text field, and you enter some other name in the text field and switch to dropdown then the error will occur because entered value is not present in choice values. Better maintain different variable for text field and map that to list later if you want. That is expected behaviour.
I have tried to replicate your issue in my code. Please have a looka!localVariables(local!companyLabels: { "XYZ corp", "ABC inc" }, local!isCompanyManuallyEntered, local!showManualCompanyNameField: false(), { a!sideBySideLayout( items: { a!sideBySideItem( item: a!dropdownField( choiceLabels: local!CompanyLabels, choiceValues: local!CompanyLabels, label: "company name:", labelPosition: "ADJACENT", placeholder: "Select Choice", value: if( or(local!isCompanyManuallyEntered), null(), tostring(index(ri!company, "companyName", {})) ), saveInto: { ri!company.companyName, a!save(local!isCompanyManuallyEntered, false()) }, disabled: or(local!showManualCompanyNameField) ) ), a!sideBySideItem( a!richTextDisplayField( value: if( or(local!showManualCompanyNameField), a!richTextIcon( icon: "minus", link: a!dynamicLink( saveInto: { a!save( local!showManualCompanyNameField, false() ), a!save(ri!company.companyName, null()), a!save(local!isCompanyManuallyEntered, false()) } ), ), a!richTextIcon( icon: "plus", link: a!dynamicLink( saveInto: { a!save( local!showManualCompanyNameField, true() ), a!save(ri!company.companyName, null()) } ), ), ) ) ) } ), a!textField( label: "Manual company Name", value: property(ri!company, "companyName", null()), saveInto: { a!save(ri!company.companyName, save!value), a!save(local!isCompanyManuallyEntered, true()) }, labelPosition: "ADJACENT", showWhen: local!showManualCompanyNameField ) })
Yes, I did the same. I have cleared the manually entered value while switching to fields. Thanks