New Document from Dialog

Hello all! We just started using the Frappe Framework and we are loving it! We are struggling a bit learning everything, but we are learning the best we can!

In a custom app, we have a button that we want to open a dialog for creating a new document. I found the Dialog API page, but do not want to re-create a creation form for a DocType that already exists.

We noticed that there is this functionality elsewhere. I am currently digging through ERPNext’s source code to find exactly how this was done, but if there is a quicker solution or a specific doc page on this, the help would be much appreciated!

I forgot to mention that this is built into a custom page. After reading through some source code, it seems

let new_trip_form = new frappe.ui.form.Form("Delivery Trip", my_page, false);

should work and the false implies that a dialog should be created.

This looks to work in theory, except I get the following error:
form.js:54 Uncaught TypeError: Cannot read property 'istable' of undefined

It seems that the form, when calling frappe.get_doc("DocType", "Delivery Trip"); is returning undefined.

setup_meta() called from form.js:39 (unable to attach as a new forum user):

frappe.get_doc() as seen in the source should be doing a call. However, the server does not log the GET call described on ln 76 in db.js;

Frappe has this option out of the box, no need to go dig the code :slight_smile:

Go into Customize Form, choose the DocType you’d like to have opened as quick entry, check the option “Quick Entry”.


Awesome! I am hoping to wrap all these changes into one Frappe app. Perhaps a little more context would help with this issue:

We are extending the recent in-house Delivery features; adding tools to build Delivery Trips off of mapped Delivery Notes+Sales Orders viewed on Google Maps. Our use case makes adding individual Delivery Notes to Trips very difficult (155+ deliveries, two trips per truck daily!) Once proofed, I would love to see its integration into ERPNext!

The page and necessary API pulls the Delivery Notes, Trips, and the Google API key. While reading and viewing Documents are fairly simple (and well documented!), we have yet to be able to create a Delivery Trip in a dialog (like Quick Entry!).

There is no need to recreate DocTypes, right? Is there a way to set the “Quick Entry” option on a Form or DocType via on app installation?

With the Quick Entry option enabled, how would I get a page button field or page action button to open the Quick Entry form?

All the help is much appreciated! Cheers.

To answer the first:

Is there a way to set the “Quick Entry” option on a Form or DocType via on app installation?

In your, add the following:

# Installation
# ------------
# before_install also an option
after_install = ""

then in your after_install function:

def after_install():
    doctype = frappe.get_doc('DocType', '<MyDoc>')
    doctype.quick_entry = 1
    return True

How would I get a page button field or page action button to open the Quick Entry form?

let new_doc = page.set_secondary_action('New <MyDoc>', () => {


Note: A Quick Entry JS object must be defined elsewhere, similar to how ERPNext’s Customer Quick Entry box is defined. Otherwise, it will just redirect to the New Document page.
Update: Turns out, even with an object like that (to add more fields), the redirect still happens.

I did not have the Quick Entry JS object I had defined built into my build.json file. The strike-through instructions above are correct.

Although, I am finding that one of the parameters needs a reload_doc method. This can be “overridden” by handing a dummy object in.