Applescript to create a new column popup menu with values pre-populated


#1

Hello everyone,

I’m having difficulty writing an Applescript that will create a new column, change the type to “popup”, and populate the value list. I only got so far as creating the column and changing the type. I was unable to add values to it.

tell application id "com.omnigroup.OmniOutliner4"
    make new column at document 1
    set title of last column of document 1 to "Types of Meat"
    set column type of last column of document 1 to popup
    set value of cell 3 of row 1 of document 1 to "Veal"
end tell```

The error is:

    error "OmniOutliner got an error: AppleEvent handler failed." number -10000 from "Veal" to missing value

Was hoping someone better at Applescript can help me with this. Thanks in advance!

Copy Column Pop-up List Style
#3

The quick and dirty way is to first make the column rich text, add items then convert to popup. However, to add items with script try this demo, best wishes Simon:

tell application "OmniOutliner"
-- based on a Rob Trew Script.
-- Demonstrates how to write items to a popup list
-- Simon Knight Sept 2014

-- To use create a popup column and select it

-- get a reference to a popup column
try
	set oCol to first selected column of front document where column type = popup
on error
	display alert "No popup column selected"
	return
end try



tell oCol
	
	tell enumerations
		set itemsCount to count
	end tell
	
	-- In real code we need to know how many items already exist
	-- This example assumes the standard new list of three items
	
	set name of enumeration index 1 to "NewItem1"
	set name of enumeration index 2 to "NewItem2"
	set name of enumeration index 3 to "NewItem3"
	
	make enumeration --adds a new item to end of list, default value "value 1"
	set name of enumeration index 4 to "NewItem4"
	
	make enumeration --adds a new item to end of list, default value "value 2"
	set name of enumeration index 5 to "NewItem5" -- sets a name of the new item
	
	-- From the dictionary:
	-- enumerations : get / make / delete  by name , index , range , relative to others, 
	--                by whose/where filter, by unique ID
end tell
	
end tell

#4

Using code from above this script creates a new pop-up column and pre-populates it with each line of the first BBEdit window.

If no BBEdit window exists it will open one but you have to run the script again.

You can save the BBEdit document for later usage.

To use it from the toolbar put it in “/Users/USERNAME/Library/Application Scripts/com.omnigroup.OmniOutliner5/” (and give it the BBEdit Icon).

-- based on a Rob Trew Script.
-- based on a Simon Knight Script

-- script creates new pop-up column and pre-populates it with lines from first BBEdit window
-- for toolbar usage put it in "/Users/USERNAME/Library/Application Scripts/com.omnigroup.OmniOutliner5/" 
-- you can save the BBEdit document for later usage

property ColumName : "Pop-up"

tell application "BBEdit"
	try
		if window 1 exists then
			set theText to text of document 1
		else
			make new window
			activate
			return
		end if
	on error
		return
	end try
end tell

set theLines to paragraphs of theText
set Values to {}
repeat with thisLine in theLines
	set end of Values to thisLine
end repeat

tell application "OmniOutliner"
	set newColum to make new column at document 1
	set title of last column of document 1 to ColumName
	set column type of last column of document 1 to popup
	tell newColum
		set theIndex to 0
		repeat with thisValue in Values
			set theIndex to theIndex + 1
			make enumeration
			set name of enumeration index theIndex to thisValue
		end repeat
	end tell
end tell