Array within an object

Evening All. A friend suggested I might want to use Node-Red as a solution to problem i'm having but as i'm new to Node-Red, I haven't got much of a clue what i'm doing with it!

We use an online quoting tool called Quotient which can send data out via webhook - Such as this:

msg.payload : Object
object
event_name: "quote_accepted"
quote_number: 5350
title: "Configure Winman SMTP relay"
quote_url: "url"
from: "someone"
for: "company"
first_sent: "2019-11-13T16:18:21+00:00"
valid_until: "2019-11-27T16:15:00+00:00"
quote_status: "Accepted"
is_archived: false
currency: "GBP"
amounts_are: "Tax Exclusive (Inclusive Total)"
overall_discount: 0
quote_for: object
name_first: "Joe"
name_last: "N"
email: "email@email.com"
company_name: "company"
phone: object
address: object
item_headings: "Configuration of SMTP relay settings on Winman Server"
total_includes_tax: 81
total_excludes_tax: 67.5
discount_amount_includes_tax: 0
discount_amount_excludes_tax: 0
selected_items: array[1]
0: object
item_code: ""
heading: "Configuration of SMTP relay settings on Winman Server"
description: "1 hour support time (remote)"

accepted: object
accepted_on_behalf: false
accepted_on_behalf_who: ""
order_number: "PO-0173617"
comments: ""
when: "2019-11-13T16:22:28+00:00"
by: object

I've got Node-Red to receive the webhook data which is then sent on to a temple file:

<html>
 <head>
 </head>   
   <body>
       <h1>Quote Accepted</h1>
      <p><b>Quote Title:</b> {{payload.title}}</p>
      <p><b>Organisation:</b> {{payload.for}}</p>
      <p><b>test:</b> {{payload.selected_items[0].heading}}</p>
      <table>
    <tr ng-repeat="(key, value) in payload">
        <td>{{key}}</td>
        <td>{{value}}</td>
    </tr>
</table>
</body> 
</html>

 I can access properties such as {{payload.title}} and {{payload.for}} but I can't seem to assess properties contained within the selected_items: array[1]. Ideally i would like to use ng-repeat to list any items in this array. 

Any help would be much appreciated. 

Thanks in advance,

Luke

The (not ui) template uses mustache not angular so array index is just ...items.0.heading... And you use {{#property}} .... {{/property}} to create an iteration

Hi Dceejay,

Thanks for getting back to me so quickly. When you say 'not ui' templete, what do you mean? I used the template node withing the UI to create the HTML template.

Thanks again for your help,

Luke

There are two template nodes - the "not ui" template node can be found in the "Functions' group of templates. The ui-template can be found in the "Dashboard' Template group.

01%20AM

Thanks for explanation Zenofmud - makes perfect sense now however I still can't seem to access the selected_items array within the payload:

msg.payload : Object
object
event_name: "quote_accepted"
quote_number: 5350
title: "Configure Winman SMTP relay"
item_headings: "Configuration of SMTP relay settings on Winman Server"
selected_items: array[1]
0: object
item_code: ""
heading: "Configuration of SMTP relay settings on Winman Server"
description: "1 hour support time (remote)"
accepted: object
accepted_on_behalf: false
accepted_on_behalf_who: ""
order_number: "PO-0173617"
comments: ""
when: "2019-11-13T16:22:28+00:00"
by: object

I assume it should be {{payload.selected_items.1}} if referenced directly but that doesn't seem to work.

Sorry if i'm being dim!

Try {{payload.selected_items[0]}}

To visualize an array, see it as a "box" [] that contains values and are indexed. Array indexes are (usually) zero based, the first item is 0. If you want the first item of items, use items[0]

Although in this case your "value" in the array is an object. You will need to determine the properties of the object.

Thank you for all your help. It now works.