Customisation in Quick Entry form for calling third party API

I am trying to add thirdy party API to populate fields in Quick Entry form. I have already achieved same while entering values in full form. Following is what I have tried so far…

File Location: my-app/public/js/pincode_quick_entry.js

frappe.provide('frappe.ui.form');

frappe.ui.form.CustomPincodeQuickEntry = class CustomPincodeQuickEntry extends (frappe.ui.form.QuickEntryForm) {
  constructor(doctype, after_insert, init_callback, doc, force) {
    super(doctype, after_insert, init_callback, doc, force);
    console.log('custom quick entry capture...');
  }
  
  render_dialog() {
    console.log('reder_dialog', this.doctype);
    if (this.doctype != 'Pincode') {
      super.render_dialog();
    }
    console.log(this.fields);
    const pincode = this.dialog.get_field("pincode");
    pincode.df.onchange = function (frm) {
      if (/^\d{6}/gm.test(frm.doc.pincode)) {
        frappe
          .call({
            method: 'my-app.api.pincode.search_pincode',
            args: { pincode: frm.doc.pincode },
            freeze: true,
            freeze_message: 'Fetching pincode details!',
          })
          .then((doc) => {
            if (typeof doc.message === 'string') {
              console.error(doc.message);
              frappe.msgprint(doc.message);
            } else if (typeof doc.message === 'object') {
              if (doc.message.name) {
                frappe.msgprint({
                  title: __('Duplicate'),
                  indicator: 'yellow',
                  message: 'Pincode already exists!',
                });
                frm.set_value('pincode', '');
                frm.disable_save();
              } else {
                frm.enable_save();
                frm.set_value(doc.message);
              }
            } else {
              console.error('Unknown response type', doc);
              frappe.msgprint("Something went wrong! please fill details manually.");
              frm.enable_save();
            }
          });
      }
    };
    super.render_dialog();
  }
};

Hook updated:

app_include_js = "/assets/my-app/js/pincode_quick_entry.js"

I tried running this code but it never printed “custom quick entry capture…” in browser console.

Also I have already referred above code in ERPNext contact_address_quick_entry.js as mentioned here and also tried this solution but still no luck.

I am stuck at this since last 4 days, any help would be appreciated.

Your app_include_js entry seems to be missing a leading slash. It should start with /assets.

1 Like

Sorry, it was a typo while copying it from actual hooks.py file.