- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2018 09:21 AM
So how would one go about accessing that and displaying certain information into the description field? I guess I am not sure how to go about this through coding it from the record producers script field.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2018 12:44 PM
It's an JSON.stringified array of objects.
So say your multirow variable set had the following variables;
Firstname, Lastname, Email
You're value of current.variables.people could be something like;
[{\"firstname\":\"Jace\",\"lastname\":\"Benson\",\"email\":\"jace@example.com\"},{\"firstname\":\"Abdul\",\"lastname\":\"Aaron\",\"email\":\"abdul@example.com\"},{\"firstname\":\"Brandon\",\"lastname\":\"Brennan\",\"email\":\"brandon@example.com\"},{\"firstname\":\"Charlie\",\"lastname\":\"Carpenter\",\"email\":\"charlie@example.com\"}]
However if you just do JSON.parse(current.variables.people) you'll get this;
[
{
"firstname": "Jace",
"lastname": "Benson",
"email":"jace@example.com"
},
{
"firstname": "Abdul",
"lastname": "Aaron",
"email":"abdul@example.com"
},
{
"firstname": "Brandon",
"lastname": "Brennan",
"email":"brandon@example.com"
},
{
"firstname": "Charlie",
"lastname": "Carpenter",
"email":"charlie@example.com"
},
]
Once you have that you can do a forEach, map, or for loop to go over it;
// the below is for testing in the browsers console
var current = {
variables: {
people: "[{\"firstname\":\"Jace\",\"lastname\":\"Benson\",\"email\":\"jace@example.com\"},{\"firstname\":\"Abdul\",\"lastname\":\"Aaron\",\"email\":\"abdul@example.com\"},{\"firstname\":\"Brandon\",\"lastname\":\"Brennan\",\"email\":\"brandon@example.com\"},{\"firstname\":\"Charlie\",\"lastname\":\"Carpenter\",\"email\":\"charlie@example.com\"}]"
}
}
// the above is for testing in the browsers console
// you're current.variables.multirowvariablename will have similiar data
var people = JSON.parse(current.variables.people);// this is now the nice array
for(var x = 0;x<people.length;x++){
var message = "Person at position " + x + " is ";
message += people[x].firstname + " " + people[x].lastname;
console.log(message);
}
/**
Output is;
Person at position 0 is Jace Benson debugger eval code:13:3
Person at position 1 is Abdul Aaron debugger eval code:13:3
Person at position 2 is Brandon Brennan debugger eval code:13:3
Person at position 3 is Charlie Carpenter
**/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 09:12 AM
Thanks jace, I have yet to implement this but I will give it a try soon and let you know how it goes. I appreciate the help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 06:46 AM
Hi Abdul,
I am working on the same functionality. Were you able to get this working?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 07:19 AM
Holly, I'm not sure if my reply makes sense, however if it does not I'd also open a new thread on this so you can ask the particulars about what it is specifically you're doing that isn't working.