Is it possible in unsaved form to use 'get_query' method with filter that contain one of form's values

Hi

My case:
In BOM form I need to filter item (finished goods) and items’s (raw material) item_codes by BOM’s field project. (Item master contain field Project). On BOM show only these items that have the same project in Items master.

It works, if I use some global value like ‘SomeInterestingProjectName’ in filters:

frappe.ui.form.on("BOM", "project", function(cur_frm) { cur_frm.fields_dict['item'].get_query = function(cur_frm) { return { filters: [[ 'Item', 'project', '=', 'SomeInterestingProjectName' ]] } };

});

But if I use in filters value from ‘cur_frm.doc.project’ or ‘cur_frm.fields_dict.project.value’ it shows:

In browsers console I can print both values ‘cur_frm.doc.project’ and ‘cur_frm.fields_dict.project.value’.

Solved. Seems, that had to use correct event (trigger) for form. Event name ‘setup’. Took a look at https://github.com/frappe/erpnext/blob/develop/erpnext/projects/doctype/timesheet/timesheet.js

My solution:

filters: { 'project': frm.doc.project }

is sufficient for filter item.

instead of

filters: [["Item", "project", "=", cur_frm.doc.project]]