I have a data field that I would like to parse out specific text to display in a list. I found the FromJSON function but am having a hard time getting it to work correctly. Right now I have the list displaying only records that have comments and would like to keep it that way.
Current list format:
Ideally, I would like the bottom comment section to read (if only one comment display that):
Delays to Dispatch
Comment: New Comment
Comment: New Comment #2
Current arcade:
Solved! Go to Solution.
FromJSON is meant to parse text, but it looks like the contents of the field is an array, so you'll need to loop through the array the pull out specific values.
var comments = $datapoint['Comments']
var comments_string = ''
if (Count(comments) > 0) {
var comment_arr = fromJSON(comments)
var output_arr = []
for (var c in comment_arr){
Push(output_arr, comment_arr[c]['comment'])
}
comments_string = Concatenate(output_arr, '\n')
}
Here's me testing it with a sample two-comment array.
FromJSON is meant to parse text, but it looks like the contents of the field is an array, so you'll need to loop through the array the pull out specific values.
var comments = $datapoint['Comments']
var comments_string = ''
if (Count(comments) > 0) {
var comment_arr = fromJSON(comments)
var output_arr = []
for (var c in comment_arr){
Push(output_arr, comment_arr[c]['comment'])
}
comments_string = Concatenate(output_arr, '\n')
}
Here's me testing it with a sample two-comment array.
@jcarlson wonderful, worked great. Thanks!