Page 2 of 2

how to pass a String into an Array to create a list of the strings.

Posted: Fri Jul 11, 2014 7:27 pm
by Andy6966317

What I was trying to do was store a list of member firstName, lastName, and ID.
Later I was going to use a list service on the firstName and lastName in order to populate a list component with all of the members in a group.

The embedded fields were an attempt to create categories that I could choose to list later.

As you can see, I need help.


how to pass a String into an Array to create a list of the strings.

Posted: Fri Jul 11, 2014 9:29 pm
by Alena Prykhodko

Andy,

As members is an array, so you can store there only primitive data types. In your case the best suits JSON string.
In Settings delete all embedded fields from members.
Remove binding to members parameter in mapping, instead add the following code to this parameter:
pre
var value = {};
value.firstName = localStorage.getItem("firstNameOfUser");
value.lastName = localStorage.getItem("lastNameOfUser");
value.ID = localStorage.getItem("userID");
return {"__op":"AddUnique","objects":[JSON.stringify(value)]};/pre