OK, I’ll try your method. But, while waiting, I tried another method like this:
- Create a custom field named ‘coi’ which linked to DocType Country
- create this function:
frappe.ui.form.on('Customer', {
coi: function(frm) {
if(frm.doc.coi) {
frappe.db.get_value('Country', frm.doc.coi, "code").then(res => {
let x = res.message
var countryCode = x.code;
});
console.log(countryCode);
}
}
});
But now the countryCode variable is undefined. Did i do wrong?