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 > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Plan: Data Calculations (custom column math) Thread Tools Search this Thread Display Modes
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??
 
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.
 
Thanks Lizard

Could you direct me to where I could find out about Applescripts. I have no experience whatsoever with them.
 
Here's Apple's official AppleScript reference: http://developer.apple.com/documenta...SLR_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:
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
 
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
 
Quote:
Originally Posted by Lizard View Post
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
 
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.
 
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.
 
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
 
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.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom data didn't migrate to 2.0? workinprogress OmniPlan General 1 2011-07-27 02:08 PM
Due column disappears in custom perspective morpheusmorph OmniFocus 1 for Mac 4 2011-05-19 10:05 AM
Can't save custom column choices rogbar OmniFocus 1 for Mac 2 2010-04-09 05:01 PM
Plan: What is the value of blank Custom Data cdpatnoe AppleScripting Omni Apps 6 2008-03-07 01:43 PM
Custom column(s) RobTrew OmniFocus 1 for Mac 2 2007-08-23 05:26 AM


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


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