Page 1 of 1

Problem with setting local storage during mapping

Posted: Sat Jan 03, 2015 5:35 pm
by Adam Garbinski

Hello Appery.

I have following problem. In my app i use local storage for storing several values during mapping to calculate final result and pass it to the list item element. It worked fine in previous version of appery builder (my app is already in Appstore), but now it works in different way. I get the same values in each item instead of different calculations for each item.

This is my mapping, the highlighted item is called 'EqPreview' and it should display different calculations for each item:
Image

This is the code I run while mapping 'EqPreview' element. You can see it uses local storage values to calculate final result and pass it to the text attribute during mapping:

Image

This is the mapping responsible for passing value from the service to local storage '_ArtEqC_Cache'. This value is used in the script shown above.

Image

As a result, all values (in blue boxes) are the same:

Image

Steps to reproduce:

1) Open the app.
2) Click this double blue line control to open side panel.
Image

3) Set the first sliding button option to 'Nie':
Image

4) Close panel.
5) In the search box type 'Banan' and press Enter.

My app is shared with you and is called '3MC'. Can you please help me fix this issue?


Problem with setting local storage during mapping

Posted: Mon Jan 05, 2015 3:20 am
by Yurii Orishchuk

Hi Adam,

Yes you should use following way to do it easier:

  1. Make link from root response element to your component.
    Details: http://prntscr.com/5on8ya/direct

  2. Click "JS" on the link from 1st step. And populate it with following code:

    pre

    //You can use "EqC" response item dirrectly here!
    var eqC = value.EqC;

    return parseInt(eqC) + 1;

    /pre

    Note: that's only an example how to use response parameters directly without local storage.. You should use your logic in this JS code.

    Regards.


Problem with setting local storage during mapping

Posted: Sat Jan 10, 2015 6:22 pm
by Adam Garbinski

Yurii,
Thank you very much! Excellent tip!
That solved my issue.
Regards,
Adam