Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

How to map a distinct array of results from a column (field) to a list?

I've created a service to get a list of distinct values for a column in the database:

{database_url}/collections/Sizes/distinct/Brand
(using the POST method);

When I test the service I get the correct result:

[
"Gap",
"Gant",
"Celio",
"Gant Test"
]

I then create my service response, which just outputs an array ($) - the column name 'Brand' is not included in the results and hence is not created in the service response.

I'm then stuck when it comes to mapping the result to a drop down list. I can map the array to the mobileselectmenuitem but I don't have a field available (Brand) to map to the Label.

Please point me in the right direction. Thanks.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to map a distinct array of results from a column (field) to a list?

Hello! Looks like a bug, we'll research it more. For now as a workaround on service Success using JS create drop down list (this should help http://docs.appery.io/tutorials/build...)

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

How to map a distinct array of results from a column (field) to a list?

Thanks but that won't really help. I don't know the values that will be in the list. They are created by the users of the app.

Any other suggestions?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to map a distinct array of results from a column (field) to a list?

You don't need to know values. All values returned from server will be in variable "data" in service success function. In variable will be array with values. You can use this variable to form drop down list as shown in example http://docs.appery.io/tutorials/build....

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to map a distinct array of results from a column (field) to a list?

Could you also post a screen shot of the database, and its structure?

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

How to map a distinct array of results from a column (field) to a list?

Here is a screen shot. There are 4 collections and the collection that I'm referencing has 7 fields +ID. All 7 fields are strings.

Hope this helps. Image

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to map a distinct array of results from a column (field) to a list?

Thanks..we are going to check why it's happening and fix it.

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

How to map a distinct array of results from a column (field) to a list?

Hello,

I've been trying the javascript approach but I can't get it to work. Mainly because I can't seem to work out how the reference the data for the array.

I was wondering whether I could try something else as a workaround. What I had in mind was to use the standard list service to pull the full list of fields so that I had my field available to map. Then to use a 'where' javascript to restrict the output to records containing distinct values for the field 'Brand.' What do you think?

Is there a piece of javascript for "where [field name values] = distinct value" ?

Thanks, Shaun

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to map a distinct array of results from a column (field) to a list?

Hi Shaun,

Could you please show us the code you tried?
What exactly you did and what's not working?

Return to “Issues”