Page 1 of 3

Query Service??

Posted: Wed May 15, 2013 9:17 pm
by Stephen Goveia

I think I just need some simple Javascript in the where parameter "Add Javascript".
But all that I've tried has not worked.
Here's what I am trying to do:

I have a collection: "Athletes" and have set up the Query service and mapped the results to a list "athlete_List"(my List service works so I know my mappings are good and should be the same for the Query Service).

Columns in Athletes collection:
raceID | Name | Email

On transition from page1 to page2 I store a local variable "raceIDLocalVar". Which matches one of the raceID's.

In page2 in the "athlete_List" I want something like:

Javascript pseudo code:
If raceID of Athletes matches raceIDLocalVar
then
return the Name

Thanks...


Query Service??

Posted: Wed May 15, 2013 9:29 pm
by Igor

Do you have any errors? Can you post you Javascript code?


Query Service??

Posted: Wed May 15, 2013 9:57 pm
by Stephen Goveia

I dont think my code is even worth posting. If you could point me in the right direction, I would really appreciate it.


Query Service??

Posted: Wed May 15, 2013 11:01 pm
by Igor

It should be something like this:
code
if (localStorage.raceID==localStorage.raceIDLocalVar) {
return Name;
}
/code


Query Service??

Posted: Thu May 16, 2013 12:49 am
by Stephen Goveia

this is what I tried:

var x = localStorage.getItem("raceIDLocalVar");

if("raceID" == x )
{
return "Name";
}


Query Service??

Posted: Thu May 16, 2013 12:49 am
by Stephen Goveia

raceID and Name are in the database, not local


Query Service??

Posted: Thu May 16, 2013 3:14 am
by maxkatz

Did you check/test that localStorage.getItem("raceIDLocalVar") returns the correct value?


Query Service??

Posted: Thu May 16, 2013 3:37 am
by Igor

Add next javascript code to map field "Name".
Image
code
var x = value;
localStorage.setItem("raceIDLocalVar", "set_some_value_here");
if (x==localStorage.raceIDLocalVar) {
return x;
}
/code
or you can Set local storage variable "raceIDLocalVar" to input field element.


Query Service??

Posted: Thu May 16, 2013 10:42 am
by Stephen Goveia

Yes, it does. On page2 Load I Run Javascript
var x = localStorage.getItem("raceIDLocalVar");
alert(x);

Which shows the correct value.


Query Service??

Posted: Thu May 16, 2013 10:43 am
by Stephen Goveia

Thanks Igor but I think you should read my original post again.