Formula-dependent fields

Hi,

I have added 4 fields to my Attendance Module - Work In, Work Out, Time In, Time Out.

I want to be able to use this information to fill in the value of two other fields I’ve created.

  1. Work Hours: The number of hours an employee was inside company premises.
  2. Status: Whether the employee was Present, Late, Under Time (left early), or Absent.

I am familiar with programming but I am unsure how I can make these configurations to my added custom fields. I plan to make Work Hours and Status Read Only as I do not want anyone changing the values unnecessarily. I would like for the formula to kick in every time new data is inputted or imported.

Thanks!

I hope you have done so via Customize Form.

Open the doctype and if you check any field there we will be a small arrow pointing downwards. If you click it you expand it and you can see all properties of that one field. One of them just below Field name will be read only. Check it and you are done.

You will have to use Custom Scripts.

Hi,

Yes. I’ve already made the configurations you’ve mentioned. My problem is that I’m not sure what language the script needs to be in and where I can learn the syntax and functions used.

Thanks!

you can use

https://erpnext.org/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples

I’ve already visited this and I’m currently trying to wrap my mind around it. Are there any other resources that can help?

You can search on this forum and read Javascript code in the ERPNext repo.

I will suggest you go through the examples, and try writing it. We’ll help you correct it