I’m trying to write a script that will update the starting date and ending date for a specific task. The script I’m running is as follows.
set myIssue to "ISSUE-1234" -- The issue I'll lookup based on my custom attribute "Issue key" set newStart to date "7/19/16" set newEnd to date "7/28/16" tell application "OmniPlan" tell front document set t to lookup value myIssue in "Issue key" if exists t then log "soon to be new starting date: " & newStart log "soon to be new ending date: " & newEnd log "starting date (before): " & starting date of t set starting date of t to newStart log "starting date (after): " & starting date of t log "ending date (before): " & ending date of t set ending date of t to newEnd log "ending date (after): " & ending date of t end if end tell end tell
When I run this I get the following output.
soon to be new starting date: Tuesday, July 19, 2016 at 12:00:00 AM soon to be new ending date: Thursday, July 28, 2016 at 12:00:00 AM starting date (before): Thursday, August 11, 2016 at 2:50:00 PM starting date (after): Thursday, August 11, 2016 at 2:50:00 PM ending date (before): Monday, August 15, 2016 at 2:00:00 PM /path/to/my.scpt:...: execution error: OmniPlan got an error: The end date must come after the start date. (1)
Note that neither starting date or ending date get updated. The error relates to changing the ending date, and even if I comment that out the starting date update still doesn’t take.
Am I missing something obvious?