For a Task form I've built, I want to be able to put in the Estimated_Hours of the project, the Actual_Hours of the project and how many hours a week I want to work on a project, Weekly_Hours. If the (Estimated_Hours-Actual_Hours) is less than the Weekly_Hours originally submitted, I want the Weekly_Hours to show the (Estimated_Hours-Actual_Hours) to have a better idea of how many hours per week you have committed to a project.
For example, I'm working on project X and at the beginning of the project I think it will take 40 hours to complete and I want to work on it 12 hours a week until the project is complete. Well come week 4 of working on the project, there's only 4 hours remaining in the project so I want the Weekly_Hours to change for that week from 12 hours to 4 because I only need to dedicate 4 hours to the project that week.
How do I accomplish this? I keep trying IF statements and they don't seem to work. I've tried it in a formula field, in the script and it keeps giving me errors. Essentially it's:
if(Estimated_Hours-Actual_Hours) < Weekly_Hours then Weekly_Hours=input.(Estimated_Hours-Actual_Hours)
So how do I do that and where do I put it to make the formula work? And it would need to check daily/weekly to determine if if the remaining hours are less than what was originally chosen for the Weekly_Hours.