Please help my Custom Script is not working

hello everyone i just wanted anyone to check my code in custom script its not working.

frappe.ui.form.on(‘Stock Entry’,{
“refresh”: function(frm)
{
cur.frm.add_fetch(“stock_entry”, “source_warehouse”, “from_warehouse”)
}
});

Please help me!

frappe.ui.form.on(‘Stock Entry’,{
refresh: function(frm)
{
cur.frm.add_fetch(“stock_entry”, “source_warehouse”, “from_warehouse”);
}

try this

its not saving…

frappe.ui.form.on(‘Stock Entry’,{
refresh: function(frm)
{
cur.frm.add_fetch(“Stock Entry”, “source_warehouse”, “from_warehouse”);
}

@adnan
still not working sir :frowning:
i also tried this codes below but has an error it will say Source warehouse is mandatory for row 1?

frappe.ui.form.on(‘Stock Entry’,{
refresh: function(frm)
{
cur.frm.add_fetch(“Stock Entry”, “source_warehouse”, “from_warehouse”);
}
});

materialtransfer
here’s i wanted to do i wanted to fetch/copy the data whatever i input in the Source Warehouse to Default warehouse. please help me.

Try this, if it doesn’t work then double check your field names,
This script will copy your source_warehouse data and paste it in from_warehouse

frappe.ui.form.on("Stock Entry", "source_warehouse", function(frm, cdt, cdn) {

	frm.set_value("from_warehouse", frm.doc.source_warehouse);

});
1 Like

Thank you very much sir @shahid. heres the twist how can i combine with my quantity code?

frappe.ui.form.on(“Stock Entry”, “refresh”, function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_qty = 0;
$.each(frm.doc.items || , function(i, d) {
total_qty += flt(d.qty);
});
frm.set_value(“total_qty”, total_qty);
//cur_frm.add_fetch(“Stock Entry”, “source_warehouse”, “from_warehouse”)
});

You should put it seprate like

frappe.ui.form.on("Stock Entry", "refresh", function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_qty = 0;
$.each(frm.doc.items || [], function(i, d) {
total_qty += flt(d.qty);
});
frm.set_value("total_qty", total_qty);
});

frappe.ui.form.on("Stock Entry", "source_warehouse", function(frm, cdt, cdn) {

	frm.set_value("from_warehouse", frm.doc.source_warehouse);

});

Note: Copy the above and replace the old one from your script pad, because i could see that your commas are wrong (this might be also the reason for not working). i’ve made correction.

2 Likes

thank you sir… i learned something today … :blush: :kissing::kissing_heart:

1 Like