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: What is the value of blank Custom Data (http://forums.omnigroup.com/showthread.php?t=6674)

cdpatnoe 2008-01-09 03:54 PM

Plan: What is the value of blank Custom Data
 
Hi there,

I'm writing a script that to populate some Custom Data into an OmniPlan document, but I want it only to fill in the custom data is blank.

Problem is I don't seem to be able to match against empty data

[FONT="Courier New"]set OPBug_ID to the value of custom data entry "Bug ID" of this_task[/FONT]

Using Script Debugger, this custom Bug ID shows "missing value" as the value of OPBug_ID.

When I do an AppleScript Display Dialog, it prints "msng". When using say, it says "m""s""n""g".

Neither "missing value" nor "msng" will allow a match in AppleScript. Am I missing something really simple here?

Thanks!

Christopher

cdpatnoe 2008-01-09 05:21 PM

duh
 
figured an easy way around it...

[FONT="Courier New"]set OPBug_ID to the value of custom data entry "Bug ID" of this_task as string
[/FONT]
so by setting "missing value" as a string, I'm able to match against it.

Lizard 2008-01-09 05:23 PM

It's not what you're missing, it's what you've added -- the quotation marks!
The following should work:
if OPBug_ID is missing value
-- no bug id
else
-- do something with the bug id
end if

Tom Dibble 2008-03-05 05:21 PM

[QUOTE=Lizard;30790]It's not what you're missing, it's what you've added -- the quotation marks!
The following should work:
if OPBug_ID is missing value
-- no bug id
else
-- do something with the bug id
end if[/QUOTE]

That doesn't work for me. I have to get the custom data value "as string" then compare it to ""!

RobTrew 2008-03-06 07:47 PM

Empty record, i.e. empty list.

[CODE]tell application "OmniPlan"
set oTask to child task 1 of document 1
set recData to custom data of oTask
if recData = {} then display dialog "Empty"
end tell[/CODE]

Lizard 2008-03-07 11:05 AM

RobTrew: I can't get your suggestion to work on OP 1.5 once I define a custom data key, even if the value for a specific task is not specified.

I'm puzzled, because the code I posted above still works for me in both Script Editor and Script Debugger. Perhaps the behavior changed between OmniPlan 1.1.2 and 1.5?

(If you're not running 1.5 yet, I encourage you to get the upgrade -- it's free!)

RobTrew 2008-03-07 01:43 PM

Yes the previous code only reports a condition in which no custom data key exists.

The following catches missing data for an existing key (in 1.5)

[CODE]tell application "OmniPlan"
set oTask to item 1 of child tasks of document 1
set recData to custom data of oTask

set varValue to |OPBug_ID| of recData

if varValue is missing value then
display dialog "Empty !"
else
display dialog (varValue as string)
end if

end tell[/CODE]


All times are GMT -8. The time now is 04:42 AM.

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