Not able to get value from other doctype

Dear all,

I am making a print format for Employee doctype which should look like a Salary Certificate letter. This is needed by our HR.
Everything works fine, except that I am not able to fetch the net_pay from Salary Structure. Here is the HTML I used in the print format builder:

Date: {{ frappe.utils.formatdate(frappe.utils.today(), 'dd-MM-YYYY') }}
Ref : {{doc.employee }}

{{ doc.subject }}
To {{ doc.to }};

This
 is to certify that {{ doc.salutation }} {{ doc.employee_name }} holder 
of passport Number {{ doc.passport_number }} is presently employed by 
our organization {{ doc.company }} in the position of {{ doc.designation
 }} as per visa, since {{ doc.date_of_joining }}.

As per the 
company records, his monthly salary is Dhs. {{ 
frappe.db.get_value("Salary Structure", doc.employee_name, "net_pay") }}
 only, including other allowances.

This certificate is being 
issued upon his request and does not constitute any financial and other 
responsibility on the part of {{ doc.company }}.

Yours faithfully,
For and behalf of {{ doc.company }},



----------------------------------
Authorized Signatory
Mohamed Awadh Lardhi
HR & Administration Manager


Remarks:
1- This certificate is valid for only one month from the date of issue.
2- This certificate cannot be used for any other purpose other than mentioned in this letter.

When the letter is printed, I get all the fields right except the salary it shows as “None”. Can you help me fix that please?

Hi @ahmed,

Try frappe.db.get_value("Salary Structure",{"employee": doc.name}, "net_pay")

Thanks, Rohit

3 Likes

Perfect! It works now. Thank you very much.