Having dificulties to call a doctype

as you can see below, this is my code witch works

{% set c = frappe.get_doc("Customer", doc.customer) %}
{{c.contacto or "" }}

but when i try to call another doctype like Journal entry account it says doctype not found

{% set c = frappe.get_doc("Journal Entry Account", doc.Journal_Entry_Account) %}
{{c.contacto or "" }}

the code above is the one witch does not work.
help please


I assume you are trying to execute the code on Customer form, which does not have any field named Journal Entry Account. Since there is no link field that stores Journal entry on customer form.

In case you are trying to do code on Journal Entry Account then, you can get party based on party_type as ‘Customer’ which in turn gives the contact for that particular customer.

@Dany_Carvalheiro i understand what you want, but for you to make sure you use it right you better use the customize form to know the exact command to use inside of the jinja template//

you can see all commands for all forms (almost) in here:

hi, the customer form was a example. what i really want is to take a value in Journal entry where i have journal entry account,

sorry, but i can’t reach the link you gave me


@Dany_Carvalheiro change domain.domain to your domain name…

or go to setup > setup > Printing > Customize >Customize Form

yes, there i found the form of doctypes, but my isue is to call a value from jounarl entry account doctype, to a print format for doctype journal entry

@Dany_Carvalheiro you want to use the entry in the journal doc type right?
you can call it using jinja template (example {{doc.company}} )

if you want the field from another doctype you can call it by adding a link in the journal doctype.

if you dont understand please tell me exactly what you want to do and i will try to help…


this is the problem
the code on custom print is this:
{% set f = frappe.get_doc(“Journal Entry Account”, doc.journal_entry_account) %}

{{f.invoice or “” }}

@Dany_Carvalheiro there is no entry called invoice in journal entry, what do you want to do exactly ?

Uploading image.png… Uploading image.png…

Sorry having some problems in uploading using iPad
@Administrator can you please check the issue on iPad

yes i create that in my form
even if i call this below the error consiste

{% set f = frappe.get_doc(“Journal Entry Account”, doc.journal_entry_account) %}

{{f.reference_name or “” }}

i think i am writing something wrong when i call the doctype but i can’t find it

Can you show a screenshot of your doctype with the custom fields? The same as @ramielian posted.

@Dany_Carvalheiro you mean this is your custom field that you made?

if you make new custom fields it will be applicable on new documents only, so you have to cancel the document and make new one in order to show it…

also you need to make sure it is working; what did you use to get the invoice field?

It’s not a good idea to have this kind of code in a view or view template: instead you should get the object in the related controller file (.py) and pass it to the view using context object; e.g.

Controller code

def get_context(context):
    # code to get current object
    doc = get_my_doc()

    # check look-up value
    print doc.journal_entry_account

    # get object and print to console
    context.journal = frappe.get_doc("Journal Entry Account", doc.journal_entry_account)
    print context.journal

Template code

{{ context.journal.reference_name if context.journal }}

this way you can debug easily your code in the console, instead of expecting results/errors in browser window.

1 Like

there is my form

ok forget about the custom field i create,
if i want to print in my customize print witch is receipt and i want to print the invoice number in this receipt how coul i get it?

yes, thank you, but i dont know how to use the console.

@Dany_Carvalheiro I think I know what you need but it shouldn’t be made in custom field at all because it’s already there…

Use the reference type to know what’s the reference and then make an if command to say {% if doc.reference_type = sales invoice%} {{doc.reference name}} {% endif %} ( I think there is an alternative to the equal sign…

If you want the invoice information use this also

{% set in = frappe.get_doc(“Invoice”, doc.reference_name) %}
{{in.name or “” }} or what ever you need from the invoice…