Hi,
I want to Fetch Data from Multple Doctype into sales Invoice Print Format using jinja Template.
Is it Possible ? if possible Please Suggest ASAP.
for refrence.
{% set u = frappe.get_doc(“Risk Profile”, doc.rpd_id) %}
{{ u.age_group or ‘’ }}
Hi,
I want to Fetch Data from Multple Doctype into sales Invoice Print Format using jinja Template.
Is it Possible ? if possible Please Suggest ASAP.
for refrence.
{% set u = frappe.get_doc(“Risk Profile”, doc.rpd_id) %}
{{ u.age_group or ‘’ }}
Please Help!
{% set u1= frappe.get_doc(“Doctyp 1”, doc.doc_id)
set u2= frappe.get_doc(“Doctyp 2”, doc.doc_id)
set u3= frappe.get_doc(“Doctyp 3”, doc.doc_id)
%}
{{ u1.age_group or ‘’" }} - {{ u2.age_group or ‘’" }} - {{ u3.age_group or ‘’" }}
Hi @Mohammed_Redha Thans for quick reply.
what i actually wanted let see the below example
// it’s filter data from customer
{% set u1= frappe.get_doc(“Customer”, doc.customer)
// i want to fetch Data from Leads (I.E Sales Invoice Connected with Customer but not connected with Leads.
set u2= frappe.get_doc(“Lead”, u1.lead_name)
%}
{{ u2.name }}
Thanks
@Mohammed_Redha
Code
{% set u1= frappe.get_doc(“Customer”, doc.customer)
set u2= frappe.get_doc(“Lead”, u1.lead_name)
%}
{{ u2.name }}
but I am getting below erro
this will work:
{% set u1= frappe.get_doc("Customer", doc.name) %}
{% set u2= frappe.get_doc("Lead", u1.lead_name) %}
{{ u2.name }}
@Mohammed_Redha
This is working fine but in another doctype field entity_name is Data field type which is connected with Lead ID.
Is it possible to filter without link type field ?
below Code
{% set u1= frappe.get_doc(“Customer”, doc.customer) %}
{% set u2= frappe.get_doc(“Lead”, u1.lead_name) %}
{% set u3= frappe.get_doc(“Risk Profile”, u2.name) %}
{{u1.lead_name}}
{{u2.entity_name}}
{{u3.name}}
Thanks
entity name is the field in Risk Profile doctype.
in that lead_name is stored.
but now when we want Risk Profile details from lead_name it is not coming
@hari.kishor becuse frappe.get_doc will bring only document by primary key .
to make filter with another field you have to use frappe.get_list:
frappe.get_list("ToDo", fields=["name", "description"], filters = {"owner":"test@example.com"})
@hari.kishor let me ask you something , is it possible “entity_name” value to be in multiple record?
@hari.kishor then “entity_name” is Unique. if so, try this:
{% set u1= frappe.get_doc(“Customer”, doc.customer) %}
{% set u2= frappe.get_list(“Lead”, fields=[“entity_name”], filters = {“entity_name”:u1.lead_name}) [0]%}
{% set u3= frappe.get_doc(“Risk Profile”, u2.name) %}
{{u1.lead_name}}
{{u2.entity_name}}
{{u3.name}}
@Mohammed_Redha it’s giving below errors
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 65, in get_doc
raise ValueError(‘“doctype” is a required key’)
ValueError: “doctype” is a required key
pls use this
{% set parent = frappe.db.get_value(‘Dynamic Link’,{‘company’:doc.comapny},‘parent’)%}
{% set age_group = frappe.db.get_value(‘Risk Profile’,{‘name’:doc.rpd_id},‘age_group’) %}
this should work now
{% set u1= frappe.get_doc(“Customer”, doc.customer) %}
{% set u2= frappe.get_doc(“Lead”, u1.lead_name)%}
{% set age_group = frappe.db.get_value(‘Risk Profile’,{‘entity_name’:u2.name},‘name’) %}
{{age_group}}
Thanks, that’s working.
one more query :