Skip to content

Instantly share code, notes, and snippets.

@nathando
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save nathando/740b3eb9131fafb029e8 to your computer and use it in GitHub Desktop.

Select an option

Save nathando/740b3eb9131fafb029e8 to your computer and use it in GitHub Desktop.
Ajax client test
cur_frm.cscript.employee = function(doc,dt,dn){
return $c_obj(doc, 'get_emp_and_leave_details','',function(r, rt) {
console.log("default=====");
var doc = locals[dt][dn];
cur_frm.refresh(); // Once this called, the changes made using customize script are reverted
calculate_all(doc, dt, dn);
});
}
cur_frm.cscript.custom_employee = function(doc, dt, dn) {
frappe.call({
method:"frappe.client.get_value",
args: {
doctype: "Sales Person",
fieldname: "name",
filters: {employee: doc.employee}
},
callback: function(data) {
// There is one sales person tied to this employee
if (data.message)
{
console.log(data.message);
cur_frm.set_value("sales_person", data.message.name);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment