I have set the select fieldtype options dynamically in report but that options can’t show in that dropdown. I have to refresh that particular dropdown to view new assigned options of that dropdown. Is there any function available to refresh the particular filter of report…?
{
"fieldname":"party",
"label": __("Party name"),
"fieldtype": "Dynamic Link",
"get_options": function() {
var party_type = frappe.query_report.filters_by_name.party_type.get_value();
var party = frappe.query_report.filters_by_name.party.get_value();
party_input = $(".page-form").find('[data-fieldname="party"]').find('input');
frappe.call({
method: 'erpnext.accounts.report.general_ledger.general_ledger.get_select_values',
args: {
"party": party_input.val()
},
callback: function(r) {
if(r.message)
{
options = []
for (i = 0; i < r.message.length; i++) {
options[i]= r.message[i]
}
frappe.query_reports["General Ledger"].filters[6].options = options
refresh_field('party_type'); // Looking for something like this...
console.log(frappe.query_reports["General Ledger"].filters[6].options)
}
}
});
return party_type;
}
}
1 Like
I’m not 100% sure it will work this a query report, but you can try:
this.trigger_refresh_on_change(["party_type"]);
I know it works for GridReportWithPlot…
@nishith i used:
return frappe.call({
method: "path.to.get_user_warehouse",
"args": {
"user": frappe.session.user
},
callback: function (r) {
if (r.message) {
var warehouse_filter = frappe.query_report_filters_by_name.warehouse;
//warehouse_filter.df.options = r.message; <-- modify options
warehouse_filter.df.default = r.message[0];
warehouse_filter.df.read_only = 1;
warehouse_filter.refresh();
warehouse_filter.set_input(warehouse_filter.df.default);
}
}
});
it worked fo me
2 Likes