The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   Plan: Data Calculations (custom column math) (http://forums.omnigroup.com/showthread.php?t=7474)

Juljon 2008-03-12 06:35 AM

Plan: Data Calculations (custom column math)
 
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 2008-03-13 10: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 2008-03-13 05:04 PM

Thanks Lizard

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

Lizard 2008-03-14 06:27 PM

Here's Apple's official AppleScript reference: [url]http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html[/url]

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:
[CODE]
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
[/CODE]

Juljon 2008-03-15 06: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 2008-06-28 04:04 PM

[QUOTE=Lizard;34491]
Here's an example of an AppleScript that does approximately what I described above:
[/QUOTE]
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 2008-06-29 08: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 [email]omniplan@omnigroup.com[/email], I can try and see what's going awry for you.

whpalmer4 2008-07-03 10: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.

Lizard 2008-07-08 11:24 AM

whpalmer4: We haven't seen that behavior in-house, even with the example you sent in. If you're running Tiger, it's possible the behavior changed with Leopard.

If you don't care about the decimal places on other values, you could cast a couple of the calculations to integers and see if that helps.

[CODE] set foo to (x / y) as integer [/CODE]

whpalmer4 2008-07-08 07:22 PM

I just confirmed that it still happens in the 1.6 SP under Tiger. I guess what you're implying is that you don't handle the formatting of these numbers? The script editor "debugger" does show the expected format, which makes it more interesting to me.

In any case, I simply pointed it out because it looks ugly, and figured no one would argue otherwise. If I was an OmniPlan developer, I wouldn't be happy about it if I knew about it, unless it was something out of my control. It has no adverse impact on my ability to use OmniPlan, so I won't be inconvenienced in the slightest if you choose to do nothing.


All times are GMT -8. The time now is 12:38 AM.

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