I have inserted custom field for Salary Structure Assignment in Additional Salary doctype,
The field name and field label are ssa and Salary Structure Assignment respectively,
How do I fetch the recent Salary Structure Assignment of employee.
From Anurag, following code works.
setup(frm) {
// This will fetch all SSA options if in case you want to change.
frm.set_query('ssa', function(doc) {
return {
filters: {
"employee": cur_frm.doc.employee
}
};
});
},
employee(frm){
//this will fetch and set the most recent assignment.
frappe.db.get_link_options('Salary Structure Assignment', '',
{
employee: cur_frm.doc.employee
}
).then(all_ssa =>{
frm.set_value('ssa', all_ssa[0].value)
})
}
})