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?

Hi,

Thanks. Attached is a screen shot. I don't really know what I'm doing...

I've created an event on the data side and included some javascript. I'm not sure how to reference the data and I'm sure there are other errors...

Image

I then have the fill_brand_dropdown run as an event on the Design side:

Image

Thanks for your time.

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?

Sorry. Just realised that I attached the javascript event to the wrong component in the first screen shot. I've now attached it to fill_brand_dropdown but I still can't get it to work.

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,

To get server data on Success event add Run JavaScript action where access the first item of "arguments" pseudo-array: arguments[0].

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'm sorry Katya but I don't understand what you are telling me. I have the "on Success, run Javascript" in place. What does this mean: "where access the first item of "arguments" pseudo-array: arguments[0]."

If you have time then code you give me an example.

Thanks.

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,

All Appery.io event handlers do not have parameters transmissions described in the code. But the parameters are always passed anyway. They just do not have a name. The built-in JS pseudo-array "arguments" that is always accessible within functions is used to access them. This object contains the passed parameters as array elements.

In the case of action on Success event, the data comes in the first argument of the function, and therefore are available in arguments [0].

That is, to get the response data you would need the following JavaScript code:
codevar data = arguments[0];
// here you can try check it by uncomment next line
// alert( JSON.stringify( data ) );/code

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?

Much clearer. Thanks. I'll give it a go.

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?

Hi,

I'm sorry to come back again. I can get the values using the code that you gave me and it works when I try the alert. But when I try and populate the dropdown list I get nothing. This is the javascript I'm using:
code
var data = arguments[0];

var dropDown = $('select_brand');
$.each(data, function(index, option) {
mySelect.append(
$('<option><&#47;option>')&#46;index(index)&#46;option(option)
);
});
/code

Please tell me where I'm going wrong.

Thanks

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?

Hi,

I found an error but still can't get it working. Most frustrating. I'll be happy when you've resolved the original bug that forced me into this workaround.

code

var data = arguments[0];

var dropDown = $([name=select_brand]);
$&#46;each(data, function(index, option) {
dropDown&#46;append(
$('<option><&#47;option>')&#46;index(index)&#46;option(option)
);
});
/code

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,

Your code is incorrect and won't work. Please use mapping to fill list.

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?

How do I do that? I've got nothing to map. That was the original problem.

Sorry if I'm missing the obvious.

Return to “Issues”