Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

JS not able to identify array name

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?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

JS not able to identify array name

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

Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

JS not able to identify array name

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?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

JS not able to identify array name

Anil,

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

Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

JS not able to identify array name

Thanks Evgene. That worked.

Return to “Issues”