Multi-select fields injects flat array instead of grouped array (I think it is a bug)


I’m running into an issue where I’m trying to generate an HTML table in calc field as a summary from multiple related items. Everything works except for the Multi Select field in a related item.

Here’s the setup: const entitlements = @All of Entitlements with nulls ;

One field from the related item - Entitlements - is a multi-select fields. So in each related item, this particular field might have one value, two values or more.

so I would expect the following to be an array of arrays.

const entitlements = @All of Entitlements with nulls ;

Instead it is a flat single array.

For example, the output looks like:

Product 1: Apple,Mango,Orange,Apple, Mango
Product 2: Apple,Mango,Orange,Apple, Mango
Product 3: Apple,Mango,Orange,Apple, Mango

Instead of what I expect:

Product 1: Apple,Mango,
Product 2: Orange
Product 3: Apple, Mango

The number of entitlements per product can vary, so slicing the array by a fixed size isn’t reliable. It seems like Tape isn’t grouping the entitlements per row/product when using @All of ... with nulls.

Code from calc:

const formatDate = d => {
 const date = new Date(d)
 return isNaN(date) ? '' : date.toDateString()
}
// collect all fields (Tape injects them)
const names = @All of Name with nulls
const creation = @All of Creation Date with nulls
const entitlements = @All of Entitlements with nulls
let html = ''

html += '<table style="border-collapse:collapse;font-family:system-ui,Arial,Helvetica,sans-serif;font-size:12px;width:100%;border:1px solid #ccc;">'
html += '<thead></thead><tbody>'

const total = Math.max(
 names.length, creation.length, entitlements.length
)

for (let i = 0; i < total; i++) {
 html += '<tr>'
 html += `<td style="padding:4px;border:1px solid #ddd;">${names[i] || ''}</td>`
 html += `<td style="padding:4px;border:1px solid #ddd;">${formatDate(creation[i])}</td>`
 html += `<td style="padding:4px;border:1px solid #ddd;">${entitlements || ''}</td>`
 html += '</tr>'
}
html += '</tbody></table>'
html```
2 Likes