Skip to main content

I'm trying to create a table in Zapier, but I'm facing an issue with my data format. The data I have comes as a list, and I want to display it in a single table format with columns for ID, Name, and Namespace. However, I'm currently unable to iterate over these individual fields correctly.

Instead of generating one table with all the rows, I'm ending up with a separate table for each ID, which is not what I want. Can anyone guide me on how to properly iterate over the parent object that contains this data so that I can create a single cohesive table?

Thanks in advance for your help!

 

 

Hi ​@mjanwani 

Help us have more info by posting screenshots showing how your Zap Code step is configured in EDIT mode along with the format of the data used for the input variables.


 

output = {

tableLength: table.length,

rows: table

};


----------

I wanted to refer rows 
not rows.id


@mjanwani 

Try asking ChatGPT for help with your javascript code.

Your inputs do not match your inputData.XXX declarations in the code.

 

 


Hi
I am not using expiringDates at this minute, that is ok,
rest piece is fine.
I also added the outputs I get from it.
 


@mjanwani 

Did you try updating the code based on the feedback from AI?

 

 


I don’t think that is the issue, stll I updated- didn’t work


 

 


@mjanwani 

For us to have current context, you need to post screenshots showing how your Zap steps are currently configured.

Also, post the data being used for the Code step inputs.


Hi 
Sure,
Kindly review 

 

I want this JS output in a table.
Thanks


@mjanwani 

Try this code.

If you are still stuck, try asking ChatGPT for help.

Make sure to provide ChatGPT with

  • the actual javascript code.
  • the actual input var values:
    • JSON for dataResponse
    • comma delimited text string for expiringNamespaces
  • screenshots showing the generated output
const dataResponse = inputData.dataResponse || '{}';
const expiringNamespacesStr = inputData.expiringNamespaces || '';

// Parse inputs
const parsedData = JSON.parse(dataResponse);
const records = parsedData.records || |];
const expiringNamespaces = expiringNamespacesStr
.split(',')
.map(s => s.trim())
.filter(Boolean);

// Start building HTML table
let html = '<table border="1" cellpadding="4" cellspacing="0"><thead><tr>';
const headers = 'Id', 'PackageName', 'NamespacePrefix'];

// Add header row
for (const header of headers) {
html += `<th>${header}</th>`;
}
html += '</tr></thead><tbody>';

// Add data rows
for (const record of records) {
const namespacePrefix = record?.SubscriberPackage?.NamespacePrefix;
if (namespacePrefix && expiringNamespaces.includes(namespacePrefix)) {
html += '<tr>';
html += `<td>${record.Id || ''}</td>`;
html += `<td>${record.SubscriberPackage?.Name || ''}</td>`;
html += `<td>${namespacePrefix}</td>`;
html += '</tr>';
}
}

html += '</tbody></table>';

// Return full HTML string
return { htmlTable: html };

 


I'm trying to create a table in Zapier, but I'm facing an issue with my data format. The data I have comes as a list, and I want to display it in a single table format with columns for ID, Name, and Namespace. However, I'm currently unable to iterate over these individual fields correctly.

Instead of generating one table with all the rows, I'm ending up with a separate table for each ID, which is not what I want to Just click here. Can anyone guide me on how to properly iterate over the parent object that contains this data so that I can create a single cohesive table?

Thanks in advance for your help!

 

 

Zapier is creating a separate table for each item because it's treating each object in your list individually. To fix this, you need to loop over the list using “Looping by Zapier,” then collect each field (ID, Name, Namespace) into line items. After that, use a Formatter step to join the values together into a single block of text that looks like a table. This way, Zapier won’t split them into separate outputs, and you’ll get one clean table instead of many.


Reply