Hii All,
I am trying to create on custom function in js file of stock_enrty.js file. i am trying to call that function using this keyword but getting error like
VM22272:301 Uncaught (in promise) TypeError: Cannot read property ‘set_receipt_type_value’ of undefined
at is_replace_against_material_issue (eval at setup (script_manager.js:155), :301:9)
at runner (script_manager.js:90)
at script_manager.js:108
This my function:
set_receipt_type_value: function(fieldname, value) {
console.log(“In Side Function set_receipt_type_value”)
for (var i=0, l=(this.frm.doc.items || []).length; i<l; i++){
console.log(“In Side function for loop”)
var row = this.frm.doc.items[i];
frappe.model.set_value(row.doctype, row.name, fieldname, value);
}
refresh_field(“items”);
},
This the way i am trying to call:
is_return_against_material_issue : function(frm){
if(!frm.doc.is_replace_against_material_issue && frm.doc.is_return_against_material_issue){ console.log("nrep + ret") this.set_receipt_type_value("receipt_type", "Returned Item"); } else if(frm.doc.is_replace_against_material_issue && !frm.doc.is_return_against_material_issue){ console.log("rep + nret") this.set_receipt_type_value("receipt_type", "Replaced Item"); }else{ console.log("nrep + nret") this.set_receipt_type_value("receipt_type", ""); } },
Guys can you please help me what am doing wrong here. Thanks in advance.