Frappe.get_doc returning None

Hi All,

In Sales Invoice Print format , i’m trying to fetch Delivery Note details for each Sales Invoice item but its not working!
Any changes required in below code:

{% set delivery_note_data = frappe.get_doc({“doctype”:“Delivery Note Item”, “item_code”: “R1002”}) %}

{% set delivery_note_data = frappe.get_doc(“Delivery Note Item”, “R1002”) %}

Thanks,
Ragh.

@ragh The frappe.get_doc has a syntax as frappe.get_doc("Delivery Note Item", "name")
I think there is not going to be any delivery note item with name “R1002” since its a child table of Delivery note and the name for this table are hash automatically generated and hence you are getting this error.

Is there any way to pass item_code as argument for Delivery Note Item?

Well I am zero at the javascript syntax so I can probably give you an idea only, also item_code is going to be not very specific since there could be rows with same item code as well just bear in mind as well.

Also I am just enclosing a part of my print format code for Sales Invoice where doc.items would be the table name for Sales Invoice item, I hope this gives you an idea

<table class="table table-condensed table-hover table-bordered">
		<tr>
			<th>Sr</th>
			<th>Description</th>
			<th>HSN/SAC</th>
			<th class="text-right">Qty</th>
			<th class="text-right">Rate</th>
			<th class="text-right">Amount</th>
		</tr>
		{%- for row in doc.items -%}
		<tr>
			<td style="width: 3%;">{{ row.idx }}</td>
			<td style="width: 50%;">{{ row.description }}</td>
			<td style="width: 7%;">{{ row.gst_hsn_code }}</td>
			<td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
			<td style="width: 15%; text-align: right;">{{
				row.get_formatted("base_net_rate", doc) }}</td>
			<td style="width: 15%; text-align: right;">{{
				row.get_formatted("base_net_amount", doc) }}</td>
		</tr>
		{%- endfor -%}
	</tbody>
</table>

Thanks for your quickly response @adityaduggal This code will work for only to iterate Sales Invoice Doc items.
Scenario is: For each Invoice item, i should fetch/check Delivery Note Item details.
So, any suggestions for that?

If you delivery note is linked to the Sales Invoice your job can become easy.

@ragh It would be very easy to help if you explain clearly and descriptively as to what are you trying to achieve?

Besides I gave you an example which can easily be replicated to Delivery Note table as well only if one knows how and what is to be achieved.

Thanks for your support @adityaduggal and @root13F
I’m trying your suggestions!