The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniPlan General (http://forums.omnigroup.com/forumdisplay.php?f=37)
-   -   Setting Task Custom Data using Applescript (http://forums.omnigroup.com/showthread.php?t=4526)

jubo 2007-08-14 08:56 AM

Setting Task Custom Data using Applescript
 
I want to use some external scripting to set the custom data field "Username" to some value. I can set the other fields like note or name, but I am having trouble setting the custom data. I used AS Dictionary to generate some form of documentation for the Applescript library, but it doesn't give me too much information about what parameters the method is expecting. Can someone help out by giving me a snippet to use?

Also, is there a place for the official AS documentation for Omniplan?

Thanks,
Curtis

RobTrew 2007-08-14 09:23 AM

The dictionary itself contains the only documentation I know of.

You can assign anything, regardless of type, to the "custom data" property of any task, project, or resource. Its up to you to structure the data yourself.

[CODE]tell application "OmniPlan"
tell first document
set oTask to make new task

set strAnything to "This could be any string"
set custom data of oTask to strAnything

--Or, for example ...

set lstAnything to {"this", 45, "could", "B", "any", {"list"}}
set custom data of oTask to lstAnything

--Or perhaps more usefully ...

set lstAnything to {{"name", "schweik"}, {"rank", "private"}, {"age", 35}}
set custom data of oTask to lstAnything

end tell
end tell[/CODE]

jubo 2007-08-14 11:00 AM

I am running this script and it indeed creates a new task in Omniplan, but none of the custom data fields get set or created when I run the snippet above. Any ideas?

RobTrew 2007-08-14 12:36 PM

Try assigning a record as below, then check the Custom Data inspector in Omniplan.

[CODE]tell application "OmniPlan"
tell first document
set oTask to make new task

set recCustom to {surname:"Svejk", rank:"footsoldier", age:"28"}
set custom data of oTask to recCustom

end tell
end tell[/CODE]

Lizard 2007-08-14 12:40 PM

It can't really be just any list. It should be a record, like so:

[CODE]
set newData to {bugID:12345, customer:"Joe Smith"}
set custom data of oTask to newData
[/CODE]

That will give you two custom data keys called "bugID" and "customer" which are available to all tasks, not just this one.

RobTrew 2007-08-14 01:52 PM

There seems to be a GUI refresh bug here.

If you create new fields through Applescript, their data is not displayed until the user explicitly clicks in each field, or closes and reopens the document.

I have filed a bug report through the feedback dialog.

skwirl 2007-08-22 10:05 AM

[QUOTE=RobTrew;19321]There seems to be a GUI refresh bug here.

If you create new fields through Applescript, their data is not displayed until the user explicitly clicks in each field, or closes and reopens the document.

I have filed a bug report through the feedback dialog.[/QUOTE]

Received your bug report. Thanks RobTrew!


All times are GMT -8. The time now is 01:26 AM.

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