The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniPlan > OmniPlan Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Working Hours For A Day In Applescript Thread Tools Search this Thread Display Modes
Apologies if this has been posted elsewhere but I couldn't find a related post. I am writing an AppleScript to go through a project and calculate the number of days of slack from one task to the next closest dependent. I am setting "Slack" as a custom data object.

What I am trying to figure out is how to access the working duration for a specific date so I can see if should be counted in the calculation. I think I have been just staring at the code too long while trying to get other work accomplished. I have set the date to check as a date object called check_day. The last interation I tried was:

Code:
calendar day schedule of schedule of front document of check_day
Any thoughts? I have recently got a group of people here at work to order OmniPlan for their Macs but slack calculation was a requested item so I am trying to wow them by showing the extensibility.

Thanks for any help you can provide!
Brian
 
Code:
tell application id "com.omnigroup.OmniPlan"
	
	set oSchedule to schedule of project of document of front window
	set dteCalDate to date "Wednesday, March 24, 2010 00:00:00"
	
	set oCalDaySchedule to my Date2CalDaySchedule(oSchedule, dteCalDate)
	if oCalDaySchedule is not missing value then
		set strStart to start time of oCalDaySchedule
		set strEnd to end time of oCalDaySchedule
	end if
end tell

on Date2CalDaySchedule(oSchedule, dteCalDate)
	using terms from application "OmniPlan"
		tell oSchedule
			set lstCalSchedule to calendar day schedules where specific date = dteCalDate
			
			if length of lstCalSchedule > 0 then
				first item of lstCalSchedule
			else
				missing value
			end if
		end tell
	end using terms from
end Date2CalDaySchedule

Last edited by RobTrew; 2010-03-21 at 06:04 AM.. Reason: (redrafted as a function)
 
Thanks for the code! This doesn't get me 100% there but definitely helps. This appears to return some value only if the specific day waivers from a standard working day.

Last edited by bjmclaughlin; 2010-03-22 at 04:56 AM..
 
Didn't know if anyone was interested but here is my solution, as a subroutine, to determine if a date is a working day or not. If your project is working on a lower granularity than days this can, hopefully, provide a good starting point.

Code:
on isWorkingDay(_date)
    tell application "OmniPlan"
        tell schedule of project of document of front window
			
            -- Check that the _date is not a calendar exception (such as a holiday)
            if first item of (calendar day schedules where specific date is _date) is not missing value then
                return false
				
            --  Also check and see if the day of the week is a normal working day
            else if duration of item (weekday of _date as integer) of week day schedules is 0 then
                return false
				
            -- Otherwise, it is a working day
            else
                return true
            end if
        end tell
    end tell
end isWorkingDay
 
Hi.....
I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your web site to check out the latest stuff you post.
Thanks
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing working hours in forecast view xkaly OmniFocus for iPad 2 2012-04-08 02:34 PM
Duration not to be connected to working hours lorew OmniPlan General 3 2011-10-11 10:07 AM
View "Total Hours" in units of "hours" pheller OmniPlan General 4 2009-11-17 01:37 PM
Applescript action not working in presentation view Blake OmniGraffle General 3 2009-01-16 07:01 AM


All times are GMT -8. The time now is 09:02 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.