×

Cleanup & Restore

Now that you’ve completed the tutorial, there’s a few more scripts to run before finishing.

DO THIS ►

Enter and run the following script that will remove the “Staff Meeting” task from the Inbox:

deleteObject(taskNamed("Staff Meeting"))
omnifocus://localhost/omnijs-run?script=try%7BdeleteObject%28taskNamed%28%22Staff%20Meeting%22%29%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
Delete Meeting Task
 

deleteObject(taskNamed("Staff Meeting"))
DO THIS ►

Enter and run the following script that will remove the “4-Step Success” project from the library array:

deleteObject(projectNamed("4-Step Success"))
omnifocus://localhost/omnijs-run?script=try%7BdeleteObject%28projectNamed%28%224-Step%20Success%22%29%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
Delete Demo Project
 

deleteObject(projectNamed("4-Step Success"))
omnifocus://localhost/omnijs-run?script=try%7Bvar%20projectName%20%3D%20%22Inbox%2DBackup%22%0Avar%20project%20%3D%20projectNamed%28projectName%29%0Aif%20%28project%20%3D%3D%3D%20null%29%7B%0A%09document%2Ewindows%5B0%5D%2Eperspective%20%3D%20Perspective%2EBuiltIn%2EProjects%0A%09var%20alertTitle%20%3D%20%22Missing%20Project%22%0A%09var%20alertMessage%20%3D%20%22A%20project%20named%20%E2%80%9C%22%20%2B%20projectName%20%2B%20%22%E2%80%9D%20does%20not%20exist%20in%20Projects%2E%22%0A%09new%20Alert%28alertTitle%2CalertMessage%29%2Eshow%28%29%0A%7D%20else%20if%20%28project%2Etasks%2Elength%20%3D%3D%3D%200%29%7B%0A%09document%2Ewindows%5B0%5D%2Eperspective%20%3D%20Perspective%2EBuiltIn%2EProjects%0A%09document%2Ewindows%5B0%5D%2EselectObjects%28%5Bproject%5D%29%0A%09var%20alertTitle%20%3D%20%22Empty%20Project%22%0A%09var%20alertMessage%20%3D%20%22The%20project%20%E2%80%9C%22%20%2B%20projectName%20%2B%20%22%E2%80%9D%20contains%20no%20tasks%20to%20restore%20to%20the%20Inbox%2E%22%0A%09new%20Alert%28alertTitle%2CalertMessage%29%2Eshow%28%29%0A%7D%20else%20%7B%0A%09try%20%7B%0A%09%09var%20alertTitle%20%3D%20%22Confirm%20Restore%22%0A%09%09var%20alertMessage%20%3D%20%22This%20script%20will%20move%20the%20contents%20of%20project%20%E2%80%9C%22%20%2B%20projectName%20%2B%20%22%E2%80%9D%20into%20the%20Inbox%2E%5Cn%5CnPlease%20confirm%20this%20action%2E%22%0A%09%09var%20alert%20%3D%20new%20Alert%28alertTitle%2CalertMessage%29%0A%09%09alert%2EaddOption%28%22Proceed%22%29%0A%09%09alert%2EaddOption%28%22Stop%22%29%0A%09%09alert%2Eshow%28function%28result%29%7B%0A%09%09%09if%20%28result%20%3D%3D%200%29%7B%0A%09%09%09%09moveTasks%28project%2Etasks%2Cinbox%2Eending%29%0A%09%09%09%09if%28project%2Echildren%2Elength%20%3D%3D%3D%200%29%7BdeleteObject%28project%29%7D%0A%09%09%09%09Timer%2Eonce%281%2Cfunction%28timer%29%7B%0A%09%09%09%09%09%2F%2F%20show%20the%20inbox%0A%09%09%09%09%09document%2Ewindows%5B0%5D%2Eperspective%20%3D%20Perspective%2EBuiltIn%2EInbox%0A%09%09%09%09%7D%29%0A%09%09%09%7D%0A%09%09%7D%29%0A%09%7D%0A%09catch%28err%29%7Bconsole%2Eerror%28err%2Emessage%29%7D%0A%7D%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
DO THIS ►

To return the archived tasks to the Inbox, TAP|CLICK the Inbox Restore button, whose script will move the contents of the “Inbox-Backup” project back into the Inbox and then delete the empty backup project.

What’s Next?

To continue your use and study of Omni Automation in OmniFocus, visit: