Need autoselect user when creating new expense claim

Hi All,
I need autoselect user when creating new expense claim transaction or for any transactions


Thanks in Advance

Is the expense claim god? How does it know which users to select? :sweat_smile:

for example shalini devi end user in her login create expense claim it should autoselect the shalini devi employee field

possible, but if user_id linked with the employee. you can do it using the client script, it’s so simple!

you can make a user employee and then give the employee self-service role

Hi @Syed_Anas,

Even then it will not work, check it.


i already given this permissions it is not working

can u please give me a client script for this i new to erpnext and coding so please

@satyamsathya978 check this Client Script select the employee from frappe.session.user

1 Like

I think you have to understand a few concepts of client script, otherwise, you won’t know anything. So learn a little yourself, and teach people :wink:

Please check the @Jeel reference and learn:

How it work?

frappe.ui.form.on('Expense Claim', {
	refresh: function(frm) {
	    if (!frm.doc.employee) {
    	    frappe.db.get_value("Employee", {"user_id": frappe.session.user}, "name", function(value) {
    	        if (value.name) {
    	            frm.set_value('employee', value.name);
    	        }
    	    });
	    }
	}
});
3 Likes