Displaying A Linked DocType's Data

Hello. So, I have a DocType that is a list of customers, and each customer is a DocType that contains a field that is a link to a Product DocType.

I’m trying to list the customers and their respective purchases, but when I try to display the name of each product whose name is determined by a field labelled “name1,” I end up with the following:

Frank Dallas - {{ no such element: unicode object['name1'] }}
Jimmy Hopkins - {{ no such element: unicode object['name1'] }}

Here’s my code so far:

`
{% extends “templates/web.html” %}
{% block content %}

<h2> Customers </h2>
<ol>
  {% for customer in doc.customers %}
  <li>
      {{ customer.first_name }} {{ customer.last_name }} - {{ customer.order.name1 }}
  </li>
  {% endfor %}

</ol>


{% endblock %}
1 Like

You will not be able to directly access other doctype’s data inside jinja. Use get_context method to process the data first using get_doc or any other method.

Figured it out.

I used: frappe.get_doc('Product', customer.order).name1

2 Likes