ragh
May 18, 2018, 11:07am
1
Hi All,
In the above attached screen shot, inside on_change function I’m trying to make a call for displayPopUpForSalesOrderItems() on selection of Sales Orders , this method is going to be executed twice.
Any changes required in report?
Thanks && Regards,
Raghu.
This should work fine. What is not working for you?
ragh
May 18, 2018, 12:26pm
3
Its printing console statement twice.
I think it has to print once only.
1st time it is called when the input is initialized, 2nd time when it’s value is set.
ragh
May 21, 2018, 4:28am
5
Actually, In my report on selection of Sales Order’s I’m trying to display dialog box .
That dialog box pop-up is coming twice. So, is there any way to display dialog box only one time?
It will be easier to help if you can share your working code
let so = frappe.query_report_filters_by_name.so.get_value();
if(!so) return;
Did you trying doing something like this ?
Basically, just fetch and see if the so
field has been set some value or not. If not then simply return outside. You can use this at the beginning of on_change.
ragh
June 11, 2018, 10:29am
8
Thanks guys For your support.
Finally, I resolved that issue, by doing some changes in coding.
@ragh please share your code if you don’t mind
ragh
June 22, 2018, 9:43am
10
Hii @Mohammed_Redha
sorry for the late response, yeah you can find in below code:
var display_popup = true;
var docid_for_popup = “”;
frappe.query_reports[“BOM Item Warehouse”] = {
"filters": [
{
"fieldname": "for",
"label": __("For"),
"fieldtype": "Select",
"options": ["Sales Order", "Project", "BOM", "Production Order"],
"on_change": function(query_report) {
console.log("on_change....of for");
var docName = frappe.query_report_filters_by_name.for.get_value();
var docIds_filter = frappe.query_report_filters_by_name.docIds;
docIds_filter.df.options = docName;
docIds_filter.df.default = "";
docIds_filter.refresh();
docIds_filter.set_input(docIds_filter.df.default);
query_report.refresh();
} //end of on_change function..
},
{
"fieldname": "docIds",
"label": __("Doc Ids"),
"fieldtype": "Link",
"get_query": function() {
var docstatus = 1;
var docName = frappe.query_report_filters_by_name.for.get_value();
if (docName == "Project") {
docstatus = 0;
}
return {
"doctype": docName,
"filters": {
"docstatus": docstatus,
}
}
},
"on_change": function(query_report) {
console.log("on_change....of docIds");
var docId = frappe.query_report_filters_by_name.docIds.get_value();
var docName = frappe.query_report_filters_by_name.for.get_value();
if (docid_for_popup != docId) {
display_popup = true;
}
frappe.call({
method: "nhance.nhance.report.bom_item_warehouse.bom_item_warehouse.get_sales_order_items",
args: {
"docId": docId,
"docName": docName
},
async: false,
callback: function(r)
{
console.log("display_popup----------"+ display_popup);
if (docName == "Sales Order") {
if (display_popup == true) {
//displaying dialobox..
display_popup = false;
docid_for_popup = docId;
}
}
} //end of call-back function..
}); //end of frappe call..
} //end of on_change function..
},
{
"fieldname": "hidden_bom",
"label": __("Hidden BOM"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname": "master_bom_hidden",
"label": __("Master BOM Hidden"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname": "production_bom_hidden",
"label": __("Production BOM Hidden"),
"fieldtype": "Data",
"hidden": 1
}
],
onload: function(report) {
}
1 Like