Listing detail field separated by comma's

Hi there

I have a design template and data file that contains Primary Account Holders (PAH) and Secondary Account Holders (SAH). It spits the detail fields by a unique ID no. Easy enough.

Part 1) No comes the tricky part. Is it possible to list account holders from the detail fields separated by comma’s, so that rather than displaying a detail table like the image below

it displays the detail fields like this:

Secondary Members:

Kevin Dallimore, Kris Dallimore

Part 2) Is it possible to omit a detail record if the record is the PAH. For instance, in the example above, Kevin is the PAH and Kris is the SAH. I only want to display the Kris detail record under the heading Secondary Members:

There is a field in the data that shows PAH or SAH

Any help on this would be greatly appreciated.

Cheers

Hello marrd,

It’s certainly possible to display data from detail tables in a separate way, but you’ll have to do it manually and with some javascript. I don’t know how your data is actually built, so I can’t give you exact code but… let’s assume you have a detail table called ‘holders’ and inside of it you have 2 fields: ‘name’ and ‘type’.

The record is actually just a javascript object, so the object ‘record.holders’ can be represented via an object:

[
  {
    "name": "Kevin Dallimore",
    "type": "primary"
  }, 
  {
    "name": "Kris Dallimore",
    "type": "secondary"
  }
]

In javascript there are a couple ways to display this kind of data, all of which requires looping. Here’s an example that would work in this context:

var output = "";
for (var i=0; i<=record.holders.length; i++) {
  output += record.holders[i].name + ", ";
}

result.html(output.slice(-2));

You could, of course, also add a condition somewhere in there that would ignore some values, like “if(record.holders[i].type === “primary”)” for example.

This will of course require some code, as it’s not a built-in feature at the moment.

~Evie

Thanks Evie, I will give this a go