function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lovetolearnlovetolearn 

Not sure how to go about doing this...

I have three custom objects: Employee, Day Off and Vacation Request. Vacation Request and Day Off are child objects of Employee. Vacation Request is records of vacation requests submitted by Employees and Day Off is the normal days that the Employee is off during the week. For instance, I work Monday through Friday, so my Day Off would be Saturday and Sunday. The Day Off days are recurring weekly on the same days. I am stuck on trying figure out how many Day Off days are there during a given Vacation Request. Please help. Thank you. 

hemantgarghemantgarg

So basically you need to find out the number of saturdays and sundays taht lies in Vacation request period, is it what you are looking for ?

NerdFishNerdFish

This can be done.  It can be fairly simple or somewhat complex depending on how accurate you are trying to be. 

 

If you want to do it simply, I believe you could take the end date less the start date divide that by seven.  Then take the integer; multiply that by two and subtract that number from the original number.

 

So, lets say someone requests off from a monday through the friday of the following week.  That's 12 days.  The integer of that divided by 7 is 1.  Multiply that by 2 and subtract it from your 12 and you get 10 working days.

 

What that formula doesn't account for is if someone completes their vacation request for 13 days (not likely) or someone requesting something like a friday and the following monday off.  That would be 4 days with only two being regular work days.  That can be done but it requires using functions to test which is the starting day and a series of if statements to cover the possibilities.  I could put something like that together but, alas, it would take too much time and my boss frowns upon my using up too much billable time.  :smileysad:

 

If you'd like us to put together something for you, either PM me or contact us via the web site below.  I could work out a formula that you could just plug into your SF instance.  It would just take a few hours of hashing out a formula and testing it.

 

 

NerdFishNerdFish

OH, and one more thing.  That formula would account for weekends but if you're looking to account for holidays, that becomes an entirely different ball of wax.

 

Regards

Steve

lovetolearnlovetolearn

Hi, 

 

Thanks for your help. I figured this one out. I wrote a trigger that creates a junction object between the two.