Master Detail - Query via local Storage - Correct Syntax?

This forum contains topics that were moved from Get Satisfaction
DanR
Posts: 0
Joined: Wed Sep 10, 2014 10:59 pm

Master Detail - Query via local Storage - Correct Syntax?

Post by DanR »

Hi

I'm moving from using a hidden label in a master detail page to using local storage because I need to query the DB with an AND query that has two separate variables.

I can confirm that the values are being passed to local storage as I can see them change in the Dev Tools / local storage area section when debug my app.

When I used a hidden label I use the following syntax:

return '{"Store_List":'+value+'}';

When I amended it to use the NO hidden label method I use the following but it doesn't seem to be working.

return '{"Store_List":'+Store_Id+'}';

Is the above syntax correct ?

Thanks

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Master Detail - Query via local Storage - Correct Syntax?

Post by Yurii Orishchuk »

Hi DanR,

Here is code example for you:

pre

//Repace "storeListLSV" with your lsv value.
var storeListLSV = localStorage.getItem("storeListLSV");

var whereObject = {"Store_List": storeListLSV};

return JSON.stringify(whereObject);

/pre

Also in this way you can add more lsv values to other request conditions like you need.

Regards.

DanR
Posts: 0
Joined: Wed Sep 10, 2014 10:59 pm

Master Detail - Query via local Storage - Correct Syntax?

Post by DanR »

Thanks Yurii

DanR
Posts: 0
Joined: Wed Sep 10, 2014 10:59 pm

Master Detail - Query via local Storage - Correct Syntax?

Post by DanR »

Hi Yurii

I am just struggling with this last item and maybe you can advise a syntax cheat sheet that I can refer to.

Basically no matter what I do to change the text identifier the query is come through with quotes like below.

{"Store_List":"1"}

However I need it to come through as number, what is the trick for this? As I've tried to debug it many times this evening.

Thanks

Dan

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Master Detail - Query via local Storage - Correct Syntax?

Post by Yurii Orishchuk »

Hi DanR,

You can use following code to return value as number:

pre

//Repace "storeListLSV" with your lsv value.
var storeListLSV = localStorage.getItem("storeListLSV");

storeListLSV = parseInt(storeListLSV);

var whereObject = {"Store_List": storeListLSV};
return JSON.stringify(whereObject);

/pre

Regards.

DanR
Posts: 0
Joined: Wed Sep 10, 2014 10:59 pm

Master Detail - Query via local Storage - Correct Syntax?

Post by DanR »

Hi Yurii

The issue was that the value was being passed as a string but I needed it in a number format.

I had to add parseInt() in order to get a number value

this is the final piece of code if anyone else looks up this topic:

var Store_Id = localStorage.getItem('Store_Id');
var Store_Id2 = parseInt(Store_Id);
var whereObject = {"Store_List":Store_Id2};
return JSON.stringify(whereObject);

Thanks for the help

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

Master Detail - Query via local Storage - Correct Syntax?

Post by Kateryna Grynko »

Hi Dan,

Thank you for sharing this!

Post Reply