1

I have a form variable of type external API called customersList. It is a list of customer objects. In my form, I have a Customer Name and Customer Id. For the Customer Name, I use an auto-complete widget. So, when I type something in the Customer Name field, it will give me a list of suggestions. When I click on one of the suggestion, I want the Customer Id field automatically populated with the information corresponding to the name I choose.

For example, the first object of a customersList variable which is:

customersList[0] = { "customerName" = "One Time Customer", "customerNumber" = "0000" }

Thus, when I choose Customer Name field to be One Time Customer, I want the Customer Id to be set to 0000 automatically.

I set the value of the Customer Id field to be customersList[0].customerNumber. But, it is static. (please note: customerNumber represents Customer Id)

Any tips on how to do it?

BDL
  • 21,052
  • 22
  • 49
  • 55
C. Virak
  • 11
  • 2

1 Answers1

0

Sadly the default autocomplete widget won't let you achieve such use case.
In fact the default autocomplete widget can take a list of JSON object as "Available values", can use one of the attribute of those objects as the display value ("Displayed key" property) and use it for autocompletion but it will only store this value (i.e. the one being displayed).
In your use case it means that you can use your customersList for "Available values" and customerName for "Displayed key" but you will only be able to save the customerName in "Value".

The good news is that a custom widget that do just what you want is available as a community contribution. Checkout the project page to download it and then import it in your UI Designer. An example of usage of this custom widget is also available for download from the project releases.

Antoine Mottier
  • 1,185
  • 1
  • 8
  • 13