Page 1 of 1

JS not able to identify array name

Posted: Fri Jul 18, 2014 5:50 am
by Anil Sagar

Hi, I am trying to store a DB array into local storage. To achieve this, I have used the following JS in the service response mapping where DB array (called Offer) is mapped onto a mobilegrid.

localStorage.Offer_LS = JSON.stringify(Offer);

This gives me an error in console as "Uncaught ReferenceError: Offer is not defined"

What am I doing wrong. Am I not catching the DB array correctly in Service Response Mapping JS?


JS not able to identify array name

Posted: Fri Jul 18, 2014 6:50 am
by Evgene Karachevtsev

Hello Anil,

If you map some response parameter, then in js code added in this mapping, the value of this parameter will be in the variable value


JS not able to identify array name

Posted: Fri Jul 18, 2014 7:07 am
by Anil Sagar

Do u mean I need to use the following JS:

localStorage.Offer_LS = JSON.stringify(Offer.value); ...?

It still gives the same error.

I think it's a problem with identifying the array itself in the first place and store it in local storage. Once array is identified then I can try to access the value of items within it.

Or

Pls suggest any other way of writing the JS to access my DB array (a column in collection with type array) named "Offer". Also, where should I put this JS?


JS not able to identify array name

Posted: Fri Jul 18, 2014 8:17 am
by Evgene Karachevtsev

Anil,

If you add this code to the mapping, then you should try like this:
prelocalStorage.setItem("Offer_LS", JSON.stringify(value));/pre


JS not able to identify array name

Posted: Fri Jul 18, 2014 10:55 am
by Anil Sagar

Thanks Evgene. That worked.