AppleScript:Snippet:Get active projects only

Snippet: Get active projects only

Description:

This code snippet is not intended to be used on its own. You can use it in your own scripts to work with active projects only.

tell application "Things"
	
	-- get all project IDs (including scheduled and someday)
	set allProjectIDs to id of to dos of list "Projects"
	
	-- get IDs of scheduled and someday projects
	set scheduledProjectsIDs to id of to dos of list "Scheduled"
	set somedayProjectsIDs to id of to dos of list "Someday"
	
	set activeProjects to {}
	
	-- loop over all project IDs
	repeat with projectID in allProjectIDs
		
		-- if the ID is not contained in scheduled/someday IDs, it's an active project
		if scheduledProjectsIDs does not contain projectID then
			if somedayProjectsIDs does not contain projectID then
				-- let's add the project with this ID!
				set end of activeProjects to project id projectID
			end if
		end if
	end repeat
	
	-- loop over all active projects
	repeat with activeProject in activeProjects
		-- TODO: do something here
	end repeat
	
end tell

Source Code: N/A

Download: N/A

Creator: Cultured Code