Hi guys,
May i know how do i achieve something like set value of SELECT field when one of the link doctype field is alter/choose,
My code is like this :
frappe.ui.form.on("Item Group", {
item_group:function(frm, cdt, cdn){
var itemGroup = frappe.get_doc(cdt, cdn);
console.log("item group is : " + itemGroup.item_group);
cur_frm.call({
method:"booth_crm.booth_crm.doctype.promo_code.promo_code.getRelatedItems",
args:{
item_group:itemGroup.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,''));
}
frappe.meta.get_docfield("Item Group", "item_code", cur_frm.doc.name).options = ["hello", "bye"];
}
}
})
}
});
What i want to achieve is , when go to doctype name as A , inside there is a table link to B doctype, this B got field as item_group, item_code(SELECT fieldtype), when i select item_group, it will send external service to get items return display in item_code (Select fieldtype). , i refer to some of the tutorial, i do not get how can i do it ~
Could anyone please help me?