PDA

View Full Version : Plan: Data Calculations (custom column math)


Juljon
03-12-2008, 07:35 AM
I would like to calculate data in Custom Fields. EG I have a number of budget hours to use on a task, I have to complete the task within a set time period. How many men are required to complete the task within budget?

In mpp formulas can be inserted in the fields. Is there a way to do this in Omniplan??

Lizard
03-13-2008, 11:22 AM
There is no direct way to insert formulas into fields. However, it is possible to write an AppleScript that would take the value of one (or more) custom data fields for a task, perform some calculation on them, and write the result out as another custom data field for that task. This AppleScript could be designed to do calculations for the currently selected task, or each task in the project. The script can be added to your toolbar, for convenient updating of your file.

Juljon
03-13-2008, 06:04 PM
Thanks Lizard

Could you direct me to where I could find out about Applescripts. I have no experience whatsoever with them.

Lizard
03-14-2008, 07:27 PM
Here's Apple's official AppleScript reference: http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html

I actually find Matt Neuberg's book AppleScript:The Definitive Guide (O'Reilly) more helpful.

Here's an example of an AppleScript that does approximately what I described above:

tell application "OmniPlan"
repeat with t in tasks of front document
if task type of t is standard task then
-- effort is in seconds
set budgetHours to (effort of t) / 3600
set budgetPrice to value of custom data entry "Budget Hour Price" of t
if budgetHours is missing value or budgetPrice is missing value then
set budgetTotal to 0
else
set budgetTotal to budgetHours * budgetPrice
end if
set value of custom data entry "Budget Total" of t to budgetTotal
end if
end repeat
end tell

Juljon
03-15-2008, 07:21 AM
Thanks Lizard, I've done some research and found a fair amount of information on the Apple website but it is quite involved and it seems to assume previous experience. The example you give is a big help to get me started - Thanks

whpalmer4
06-28-2008, 05:04 PM
Here's an example of an AppleScript that does approximately what I described above:

Hey Lizard,

did you actually test that script? I get errors from the attempts to get the custom data entry values (and yes, I did create them in the project before running the script). I even tried it in a different user account just to make sure it wasn't something weird with mine (as some googling about for the error in other contexts suggested it might be). I'm using OP 1.5.1

Lizard
06-29-2008, 09:37 PM
It is working for me without errors in OmniPlan 1.5.1 (with the columns created before running the script). If you could post the specific errors you're seeing here, or send them in an email to omniplan@omnigroup.com, I can try and see what's going awry for you.

whpalmer4
07-03-2008, 11:06 PM
I got it to work, not quite sure what the problem was, probably pilot error.

I did notice that if I entered 0 for the Budget Hour Price, instead of getting a nice "0" in the Budget Total column, I got the rather funky "0e+0". Feedback submitted.