Further to the error above, I'm getting an error when calling the task's context. See code snippet below
Code:
tell application id "OFOC"
set dteNow to (current date)
tell default document
-- SOME FOLDER, LET'S JUST GRAB THE FIRST WE SEE ...
set oFolder to first folder
-- ALL ACTIVE CHILD-BEARING PROJECTS ENCLOSED BY THIS FOLDER, REGARDLESS OF NESTING
set refProjects to a reference to (flattened projects of oFolder where number of tasks > 0 and status is active)
-- HARVEST THE PROGENY THEREOF (PERHAPS FILTERED) AS A LIST OF LISTS
set lstTasks to flattened tasks of refProjects where completed is false
-- FLATTEN THE LIST, IF NEED BE
set lstTasks to my FlatList(lstTasks)
set listExport to "Task Project Context Creation Date Date Due Priority" & return
repeat with task_obj in lstTasks
set taskDueDate to ""
set taskPriority to ""
if due date of task_obj is not missing value then set taskDueDate to due date of task_obj
if flagged of task_obj is true then set taskPriority to "Yes"
set listExport to listExport & name of task_obj & " " & name of containing project of task_obj & " " & name of context of task_obj & " " & creation date of task_obj & " " & taskDueDate & " " & taskPriority & " " & return
end repeat
end tell
tell application "TextEdit"
activate
make new document
set text of document 1 to listExport as text
save document 1 in "/Users/myUser/Desktop/output.txt"
end tell
end tell
on FlatList(lst)
if class of lst is not list then
{lst}
else if lst ≠ {} then
FlatList(item 1 of lst) & (FlatList(rest of lst))
else
{}
end if
end FlatList