Is there any sample code / example that set Select field type of child table based on some condition and will not affect the previous set Select field value?
Let’s said different condition set different value and will not effect previous child row ?
my implementation code is this : (but it will influence the previous Select field value )
cur_frm.cscript.item_group = function(doc, cdt, cdn) {
console.log("correct function 1");
var childTableItemGroupOnPromoCode = locals[cdt][cdn];
frappe.meta.get_docfield("Promo Code Items", "item_name",cur_frm.docname).options = [""];
refresh_field("items_table");
if(childTableItemGroupOnPromoCode.item_group){
cur_frm.call({
method:"booth_crm.booth_crm.doctype.promo_code.promo_code.getRelatedItems",
args:{
item_group:childTableItemGroupOnPromoCode.item_group,
},
callback:function(r){
if(r.message==null){
alert("Invalid in somewhere, please log out and log in again.");
}
else if(r.message!=null){
console.log("items : " + JSON.stringify(r.message.ret.items));
var items = JSON.stringify(r.message.ret.items);
var itemsSize = JSON.parse(items).length;
var itemShow = [];
for(var i=0; i<itemsSize; i++){
itemShow.push(JSON.stringify(r.message.ret.items[i].title).replace(/^"|"$/g,''));
}
var operations = [];
for (var i=0, j=itemShow.length; i<j; i++) {
var op = itemShow[i];
if (op && !in_list(operations, op)) operations.push(op);
}
frappe.meta.get_docfield("Promo Code Items", "item_name",
cur_frm.docname).options = operations.join("\n");
cur_frm.fields_dict.items_table.grid.toggle_reqd("item_name", 1);
cur_frm.fields_dict.items_table.grid.toggle_reqd("item_qty", 1);
refresh_field("items_table");
console.log("finishing");
}
}
})
}
}