Select Field, Populate Via ChildTable

Hello, I have 3 DocTypes .

Jobnum which is a parent DocType,
phase which is a child DocType,
and PO which is a child DocType.

Phase has a list of activities.

When a user creates a PO, I’d like them to be able to select from the DisplayName column of of phase.

Is this possible with a userscript? What should the user script be doing to load these values. How should the phase column be configured to support this script?

Been trying out a number of different things with zero luck for a few days, and I am at a total loss.

Thanks,
Krossell

@krossell
you want to select PO.item from phase.Display name right ?

You have to make Item field as Link field. Which is same type of Display Name. Then you can set query on Item.

Like :

frappe.ui.form.on("Jobnum", {
	onload(frm) {
		frm.set_query("item", "po", function (doc) {
			return {
				filters: {
					name: ["in", doc.phase.map((row) => row.display_name)],
				},
			};
		});
	},
});

Result:

Thank you for your details response, and video, it is kindly appreciated, we will make the changes and test, and get back to you on how it went.

I don’t think this solution will work for us, as the phases and categories are unique per jobnum, there is no master table to link up to to filter the results against.

Correct, I’d like to be able to limit the users selection to the items in the child table phasenum.