Page 6 of 9

saving labels to array

Posted: Fri Sep 27, 2013 10:26 am
by Maryna Brodina

Hi Michael! Sorry, not yet. Working on it.


saving labels to array

Posted: Fri Sep 27, 2013 4:06 pm
by Kateryna Grynko

Hi Michael,

Here is the READFAVORITES service response generated automatically:
Image
After you map favorites where you need you can parse value of each favorites element. Then assign these values to the appropriate elements.

As I can see, in favorites you get the following values:
{taxicompanyname=A 2 B Private Hire, town=BEDLINGTON, taxiemail=a href="mailto:gata2btravel@yahoo.co.uk" rel="nofollow"gata2btravel@yahoo.co.uk/a, taxiphone=01670 822021, textback=Text Back}

You can run the following code in mapping to parse values:
codevar i, j, arr, tmpArr, obj;
value = value.slice(1,-1);
arr = value.split(", ");
obj = {};
for (i = 0, j = arr&#46;length; i < j; i++) {
tmpArr = arr&#46;split('=');
obj[tmpArr[0]&#46;trim()] = tmpArr[1]&#46;trim();
}/code
As a result, you'll have all the values from needed favorites row in obj.


saving labels to array

Posted: Fri Sep 27, 2013 5:41 pm
by Michael4771079

Hi Katya,
trying to understand this

do you mean

when I update "favorites" in database with service favoritesupdate
use the above code in mapping instead of

codereturn JSON&#46;parse(value);/code

;


saving labels to array

Posted: Fri Sep 27, 2013 7:40 pm
by Michael4771079

Hi Katya,
me again:)
I tried replacing code, it didn't work,
so I am not understanding

I need to know from the point of saving the labels to array in localstorage and map it to favorites in db,
is this where the code is used?

I cant create a col in db "favorites"


saving labels to array

Posted: Fri Sep 27, 2013 11:05 pm
by Michael4771079

5 hours, no response, very unhappy


saving labels to array

Posted: Fri Sep 27, 2013 11:11 pm
by Igor

Hello Michael,

Sorry for delay, we are still working on it.


saving labels to array

Posted: Fri Sep 27, 2013 11:18 pm
by Michael4771079

Thanks for the reply,

working on what?
the process is known, otherwise Katya would not have suggested, if you understand what Katya suggested can you please forward a simple guide


saving labels to array

Posted: Fri Sep 27, 2013 11:25 pm
by Igor

Did you try to use code which Katya suggested above?https://getsatisfaction.com/apperyio/...


saving labels to array

Posted: Fri Sep 27, 2013 11:32 pm
by Michael4771079

Cheers Igor,
the service to update "favorites" from localstorage array into the db is "favoritesupdate"
I used the code Katya provided in the mapping, it didn't work.


saving labels to array

Posted: Fri Sep 27, 2013 11:45 pm
by maxkatz

Please debug and see where exactly the code fails. We will gladly help you, but you need to help us. It's challenging for us to help further when a reply is simply the code is not working. In general, custom app code is outside the scope of our support but we are still trying to help here.