How can I filter drop-down list options by using custom scripts in Aurachain?

49 views Asked by At

We are using Aurachain for some of our custom apps. And in one of these we have a user interface with a field with drop-down list which takes its values from a city and coutries catalog, and we need it to filter the values returned based on the value from another field. To be more specific, I want to have a field automatically filled with the country corresponding to the city I select from the drop-down filed.

I tried to add a custom code below in the drop-down under the ““onInit" event, and i got the error Cannot read property of indexOf” displayed in console.

//Get the values from the existing catalog named “City” let catalog = this.getCatalogValues(“”);

//Get the value for “Country” field , completetd in a previws step let otherField = this.getValue(“”);

// Populate the DDL with the catalog rows where value from “otherField” exist 1 time.this.setValues(“”, catalog, row => row.country.indexOf(“otherField”) ==0);

1

There are 1 answers

0
Rosella On

We are also using Aurachain platform for our custom apps.

Check if the column name used in the code is exactly as defined in the catalog (Country or country). E.g. row.Country.indexOf("otherField") ==0) or row.country.indexOf("otherField") ==0).

Also for the script to work as expected, you will have to make sure that the drop-down property Sort order is set to none in the UI builder. So update this line like this:

//Get the values from the existing catalog named “City”
let catalog = this.getCatalogValues("", {order: "desc", by: "code" });