Send email with table format

Hi Team,

I have created the n8n work flow to get an email and http-trigger for the Jira ticket.
Currently, below is the list of items which I am getting from the http-request in generally.

[
{
“itemlist”:
[
“switch1”,
“switch2”,
“switch3”,
“switch4”,
“switch5”,
“switc65”,
“switcq134”,
“switch534”,
“switch”,
“switch134”,
“switch11242”,
“switch24”,
“switch667”,
“switch77878”,
“switch75656”,
“switch57575”
]
}
]

I would like to print these values in table format in the send Email as below

I have selected the HTML and When I see the email in the outlook I am not able to see the table data

JSON to Table // Get the hostname data from the template variable var jsonData = {{$json.itemlist}};
        // Check if jsonData is an array
        if (Array.isArray(jsonData)) {
            // Loop through the JSON data and generate table rows
            for (var i = 0; i < jsonData.length; i++) {
                document.write('<tr>');
                document.write('<td>' + jsonData[i] + '</td>');
                document.write('</tr>');
            }
        } else {
            // If jsonData is not an array, display a single row
            document.write('<tr>');
            document.write('<td>' + jsonData + '</td>');
            document.write('</tr>');
        }
    </script>
</table>

But I am not getting the table foramt . Please help us .

Hostname

Hi @DilipChiru, how about using the HTML node to build your table? You wouldn’t even need to create an array using the Item lists node first, as it can accept multiple incoming items at once. For example:

This would be the result arriving in my inbox:

1 Like

Hi @MutedJam ,

Thank you so much for the help. I got it

I need one help and suggestions. When we have list of item for example as below.

king,
qeen,
makhir

Basically, I am trying to check the elasticsearch list of items every 24hrs. Out of 100 item is there anything missing. Currently, I am missing those " king,qeen, makhirIt " and will create a JIRA ticket saying these items are missing in last 24hrs. When we have additional item missing in next 24hrs so It will create one more ticket with all list of missing. So If we keep missing then it will create multiple tickets for one single issue.

Is there any way, So I can append the latest item for example “rocket” is the value , it should update/append the value to existing ticket and for example. if the “king” is available again in it should strike the value in the description or table.

Please help with it

1 Like

Hi @MutedJam ,

Similarly , May I know how can we send the table to http_request to print in table format in the Jira ticket.

I am working on it to create the jira ticket, But I am not able to add in table format from the HTML data.

Hi @DilipChiru,

So you essentially have one list with values such as king, qeen, makhirand another list that might be missing one (or more) of these values so you can further process the missing values? In this case you probably want to use a Merge node in Combine/Keep Non-Matches mode like so:

In this example, the first input branch would provide a list of items with values king, qeen, makhir. The second (lower) input branch only provides king and makhir. The Merge node would identify the missing item and you can further process it as needd:

With regards to Jira you will unfortunately not be able to re-use your HTML table. Afaik Jira does not accept HTML when creating a ticket. Instead you’d need to build your Jira table using a but of custom code, for example like so:

This example would create a Jira table based on the incoming data looking like so:

Hope this helps!

1 Like

Please help me using http_request . Currently, I am using onprem.

image

I have some 10 values which are missing to send in to http_request Jira creation. But when I see in the jira ticket it is printing like raw table which I took from the HTML instead of table in the deception

Hi @DilipChiru, you can also use the examples from my workflows above in an HTTP Request node. Simply reference the data using an expression such as {{ $json.table }}:

1 Like

Hi @MutedJam ,

Thanks for the reply, But I am trying to add some description for the jira ticket in the http_request.

{
“fields”: {
“project”: {
“key”: “king”
},
“summary”: “REST ye merry gentlemen.”,
“description”: “Creating of an issue using project keys and issue type names using the {{ $json.table }}”,
“components”: [{
“name”: “Security”
}],
“issuetype”: {
“name”: “Story”
}
}
}

But I am getting Invalid JSON format . I have tried all the way.

image

But getting error as below:

Hi @DilipChiru, this looks pretty much like what it says in the error message. The way you are using the expression would result in invalid JSON (because JSON doesn’t allow line breaks).

Looking at your screenshot, perhaps you want to try {{ JSON.stringify($json.table) }} instead?

Hi,

But still the issue remain same as below

I’m sorry @DilipChiru. Perhaps you want to wrap your entire JSON body in {{ and }}? Like so:

This will make it considerably easier to see whether you are producing a valid JSON object or not as n8n will shows this in the preview using [Object: at the start:

Sending the above example data works as expected:

Please share me the JSON Object which you have added, I getting multiple errors

Hi @DilipChiru, you can simply copy the HTTP Request from my example workflow above. Simply select it and press Ctrl+C. Then switch to your own canvas and use Ctrl+V.

I am sorry to ask again,
But it doesn’t contain the object related to JSON Structure. Please share me the details related to it which is GREEN in color

1 Like

Oh shoot you’re right, it very much looks like I copied an older version of my example workflow.

Here you go:

The exact expression is this one:

{{ 
{
   "fields": {
      "components": [
         {
            "name": "Security"
         }
      ],
      "description": 'Creating of an issue using project keys and issue type names using the\n' + $json.table,
      "issuetype": {
         "name": "Story"
      },
      "project": {
         "key": "king"
      },
      "summary": "REST ye merry gentlemen."
   }
}
}}
1 Like

Hi @MutedJam ,

thank you so much for the quick help. It is working as expected and I didn’t notice that {{}} if we put anything inside is considered as JS.

So sometimes if the JSON is not working so I can use the above to get it done.

Thanks

1 Like

Hi @MutedJam ,

Thanks for it, It helps me a lot and finally.
have fixed the issue.

Thanks

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.