On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
you can query the manager using a query to "webnotes.client.get_value" (see custom script example).
And if the returned value is present in the options (cur_frm.get_field("leave_approver").df.options) then you can use cur_frm.set_value("leave_approver", value) to set the value in the form.
You will have to piece these together from examples on the client script wiki page.
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
Under Property drop-down list, there is no option for leave_approver. Is it possible to create new property called leave_approver? if not, how do we handle my issue?
Mayur
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
I am trying to get the User_id of an employee who is a manager of selected employee. Using “webnotes.client.get_value” I can get the Reports_to detail for selected employee but how do I get the user_id of the Report_to employee? Do I need to call webnotes.client.get_value method twice. Any help will be appreciated. Thank.
Mayur
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
I am trying to get the User_id of an employee who is a manager of selected employee. Using "webnotes.client.get_value" I can get the Reports_to detail for selected employee but how do I get the user_id of the Report_to employee? Do I need to call webnotes.client.get_value method twice. Any help will be appreciated. Thank.
Mayur
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
What do you mean by add fetch on report_to. Is there any function called add_fetch that I can call?
Mayur On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
What do you mean by add fetch on report_to. Is there any function called add_fetch that I can call?
Mayur On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
I am sorry if I am taking lot of your time but it didn’t work. This is what I did:
- Using web interface I added a custom field called reports_to_user_id (FieldName) for Employee doctype. - On server, I modified employee.js file and added a new line for cur_frm.add_fetch(‘employee’,‘user_id’,‘reports_to_user_id’) - After that I clicked on Tools –> Clear Cache & Refresh - Then I clicked on HR–> Employee –> one of the employee - Selected an employee as Reports To. - clicked save. - i checked the value for reports_to_user_id in database and also in web using web console and it is showing null.
Am I missing something?
regards, Mayur Patel
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
I am sorry if I am taking lot of your time but it didn't work. This is what I did:
- Using web interface I added a custom field called reports_to_user_id (FieldName) for Employee doctype. - On server, I modified employee.js file and added a new line for cur_frm.add_fetch('employee','user_id','reports_to_user_id') - After that I clicked on Tools --> Clear Cache & Refresh - Then I clicked on HR--> Employee --> one of the employee - Selected an employee as Reports To. - clicked save. - i checked the value for reports_to_user_id in database and also in web using web console and it is showing null.
Am I missing something?
regards, Mayur Patel
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
- Using web interface I added a custom field called reports_to_user_id (FieldName) for Employee doctype. - On server, I modified leave_application.js file and added a new line for cur_frm.add_fetch(‘employee’,‘reports_to_user_id’,‘user_id’)
- After that I clicked on Tools –> Clear Cache & Refresh - when i tries to access cur_frm.doc.user_id or cur_frm.doc.reports_to_user_id it is coming as undefined.
How do reports_to_user_id suppose to get populated in the database?
I don’t think I really understand how this is suppose to work.
regards, Mayur Patel
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
add_fetch is a javascript function and will only work on change of the employee field in the Leave Application form.
I think the problem for you is that the employee field is auto-selected (by default) so the change trigger may not work... Let me see if we can fix this for new forms. Can you confirm if it works when you change the employee value?
For older records, you will have to write a database (update) query.
- Using web interface I added a custom field called reports_to_user_id (FieldName) for Employee doctype. - On server, I modified leave_application.js file and added a new line for cur_frm.add_fetch('employee','reports_to_user_id','user_id')
- After that I clicked on Tools --> Clear Cache & Refresh - when i tries to access cur_frm.doc.user_id or cur_frm.doc.reports_to_user_id it is coming as undefined.
How do reports_to_user_id suppose to get populated in the database?
I don't think I really understand how this is suppose to work.
regards, Mayur Patel
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
Mayur
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
I am logged in as Administrator. So by default, employee is not selected. But it still doesn’t work when I select an employee. So basically it is not working. One thing I forgot to mention that reports_to_user_id is defined as Hidden field for employee doctype. Not sure if this matters?
I can update the old records manually but I am interested in knowing how the value for reports_to_user_id will get populated in the database?
As per your suggestion about elegant solution, are you saying that I need to add webnotes.conn.set_default(“reports_to”,self.doc.report_to,self.doc.user_id) in defupdate_user_default(self): of employee.py? what does this do?
Mayur
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
I am logged in as Administrator. So by default, employee is not selected. But it still doesn't work when I select an employee. So basically it is not working.
Do you see anything in your error console? Is the employee name getting selected?
One thing I forgot to mention that reports_to_user_id is defined as Hidden field for employee doctype. Not sure if this matters?
Should not matter
I can update the old records manually but I am interested in knowing how the value for reports_to_user_id will get populated in the database?
Just as employee name is set when employee is selected.
As per your suggestion about elegant solution, are you saying that I need to add webnotes.conn.set_default("reports_to",self.doc.report_to,self.doc.user_id) in defupdate_user_default(self): of employee.py? what does this do?
Yes this will make a "default value" for "reports_to" -- so where "reports_to" field appears, this will be set as the value. I would recommend this solution.
Mayur
On Friday, March 8, 2013 11:32:17 PM UTC+11, MP wrote:
Hi,
On Leave Application page, we would like the name of the selected
employee’s immediate manager (Report To field from employee) to be selected by
default if it is one of the option in the drop-down list of Leave Approver. For
example if x is manager of y and if x is a leave approver, when y is
selected as Employee on Leave application page, we want system to select x as
default on Leave application page for Leave Approver drop-down. How can we
achieve this?
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.