Page 2 of 3

where from 2 lsv?

Posted: Thu Aug 07, 2014 12:13 am
by Yurii Orishchuk

Hi Michael,

To get your query service work correctly you can follow these sollution:

1 Open datasource mapping on request tab.

2 Find "where" request parameters and click "Add JS/Edit JS" button. http://prntscr.com/3ps6w8/direct

3 JS editor appears. Populate it with folowing JS code:

pre

//You can change these variables with values you need. But try to test with static values before.
var westlothian = "y";
var falkirk = "n";

//This is "and" login you can use "$or" if you need it.
var whereObject = {"$and": [ {"westlothian": westlothian }, {"falkirk": falkirk } ] };

return JSON.stringify(whereObject);

/pre

Regards.


where from 2 lsv?

Posted: Thu Aug 07, 2014 1:08 am
by Michael4771079

Hi Yurii,
response really appriceated,
forgive my lack of coding skills, (although logic is good:-)

coding crap!

Im not following this correctly, the current code (in screenshot) is required to query the columns required from selectmenu.
how do I intergrate this new code with required paramaters, my efforts dont work as my small brain is fried!

really appriceate the help
Best

Image


where from 2 lsv?

Posted: Thu Aug 07, 2014 9:24 pm
by Michael4771079

Hi Yurii,
I have played with this and nothing seems to work, I to restart this topic.

basically I need to use the selectmenu label as a request parameter, either direct from the component or I have the label value in ls on valuue change

Once I can use the LS variable as a request parameter and query this prameter for "y"

is there no simple way to do this

all other code is returning everything including entries with "n"

Best


where from 2 lsv?

Posted: Thu Aug 07, 2014 10:18 pm
by Yurii Orishchuk

Hi Michael,

Currently it's hard to say what you have do incorrectly. We need to see on your implementation.

Thus, please provide us your app public link and describe steps(with credentials) to reproduce your problem.

Thanks & regards.


where from 2 lsv?

Posted: Thu Aug 07, 2014 11:03 pm
by Michael4771079

Thanks Yurii,
app name "smartlocal" app id 6940259f-fdec-4deb-a273-225e3a679996

I have left the column "east and central scotland" empty of all data, this is my check that the query worked, but with every attempt of code the query will return listings from this column even though there are no enteries in the column

open app, login "q" for both name and pass ( dont use facebook connect)
when start page opens click bars icon top left,
select east central scotland and you will get a listing,
you shouldn't if I had implemented correctly, also if you make another selection nothing will change.

if you now refresh the app and login and repeat the events but use falkirk you will get a listing different than before but the result returned will be both "y" and "n" even though the code in the query was for "y" only. and again if you now choose east central scotland nothing will change

database is "smartlocal" collection name is "smartvouchers"

cheers Yurii


where from 2 lsv?

Posted: Fri Aug 08, 2014 5:23 am
by Yurii Orishchuk

Michael,

See steps to get it work:

1 Select items should have correct values: http://prntscr.com/4ap3ut/direct

2 Correct value change order. At first you need set LSV then you need invoke the service.: http://prntscr.com/4ap51p/direct

3 Modify JS code with:

pre

var whereObject = {};
whereObject[currentValue] = "y";
return JSON.stringify(whereObject);

/pre

That's all.

Regards.


where from 2 lsv?

Posted: Fri Aug 08, 2014 11:42 am
by Michael4771079

Hi,
I have followed Yurii's post

  1. changed values of selectmenu ( this was set 2 weeks ago to "y" but somehow (upgrade of platform I suspect) it changed back to what was there before!

  2. changed order of events to match Yurii's

  3. added js to mapping

    when I run this service the code is returning paramaters {"y":"y"}

    here are some more screenshots

    if I run these pramaters {"falkirk":"y"} on test tab the result is as requested

    Image Image Image Image Image


where from 2 lsv?

Posted: Sun Aug 10, 2014 9:54 pm
by Yurii Orishchuk

Hi Michael,

Currently you have these options in your select component: http://prntscr.com/4bjgyi/direct

But first step in my suggestion was:

pre

1 Select items should have correct values: http://prntscr.com/4ap3ut/direct

/pre

So please take a look carefully for suggested solution and you will get it work.

Regards.


where from 2 lsv?

Posted: Sun Aug 10, 2014 10:23 pm
by Michael4771079

Thank you Yurii,
my bad, I misunderstood your post, all is now working as you suggested,
last question on this service, as I am returning the voucher category in order to drill down to the voucher the user wants, is there a way to remove duplicates from the return of the service, or is it possible to hide the duplicates, as I only need 1 listing for any of the categories returned. screenshot below.

thanks again

Image


where from 2 lsv?

Posted: Mon Aug 11, 2014 4:37 am
by Yurii Orishchuk

Hi michael,

Here is 3 ways to do it:

1 Using "distinct" (but in this case you can only get one column name result). See details: http://devcenter.appery.io/documentat...

2 Using "generic security context". In this way you can implement some "proxy" that's can modify server answer and attach it to certain service. See details: http://devcenter.appery.io/documentat...

3 Run some JS code on "success" service event. Which is delete all repeatable items.

Here is code for you that's you can use for this way:

pre

//Note you need replace "mobileselectmenu_2" with your select component name.
var selectComponent = Apperyio("mobileselectmenu_2");

var options = selectComponent.find("option");

var optionsHash = {};

for(var i = 0; i < options&#46;length; i++){
var option = jQuery(options);

Code: Select all

 var optionText = option&#46;text()&#46;trim(); 

 if(optionsHash[optionText]){ 
     option&#46;remove(); 

     continue; 
 }; 

 optionsHash[optionText] = true; 

};

selectComponent&#46;selectmenu("refresh", true)

/pre

Regards.