Why Dynamic Dropdowns Fail in Frappe: Handling Async Options in Child Tables

Hello Frappe Community,

I’m working on a custom Doctype called Sprint Management, which includes a child table Sprint Backlog. In this child table, I have a Priority Model field that should dynamically populate classification and weightage options based on the selected model (for example, MoSCoW or Manual).

The issue:

The dynamic population works correctly the first time I open the row dialog. However, if I leave the row empty and reopen the dialog, the dependent fields no longer populate.

It seems the problem is tied to when and how the population logic is triggered. In Frappe, child table fields can be edited either inline in the grid or through the row dialog. If the population code only runs on the initial change, it may not fire again when reopening the dialog, causing the dependent fields to remain empty.

What I’m trying to achieve:

  • Ensure that classification and weightage always populate dynamically whenever the dialog opens or the field changes.
  • Avoid unnecessary repeated server calls (caching options is ideal).
  • Make the solution reliable for both grid inline editing and dialog editing.

Conceptual approach I’m considering:

  1. Bind the population logic to the child table field event using:frappe.ui.form.on(“Sprint Management”, “Sprint Backlog”, {
    priority_model: function(frm, cdt, cdn) {
    // populate classification and weightage here
    }
    });This ensures it triggers whenever priority_model changes in a row, whether inline or in the dialog.
  2. Also call the same population function on row refresh or dialog open, so reopening an empty row will repopulate the fields:frm.fields_dict[‘sprint_backlog’].grid.wrapper.on(‘grid_row_open’, function(row) {
    // repopulate fields here
    });
  3. Optionally cache the priority model options at the parent level to avoid repeated server calls.

I’d love to hear from the community if there’s a more idiomatic Frappe way to handle this, or any patterns for reliably populating child table dropdowns asynchronously.

Thank you! :slight_smile: