Turns each planned project in Notion into an Asana task with a subtask for every step, and never sends the same project twice.
Uses
AsanaNotion
Break planned projects into Asana tasks and subtasks
notionDatabaseId to blank.Set notionDatabaseId to blank.asanaProjectIds to blank.Set asanaProjectIds to blank.plannedProjects to an empty list.Set plannedProjects to an empty list.notionErrorIf a step below fails, save the error as notionErrorTry
notionDatabaseId. Save it as plannedWork.Find pages in notionDatabaseId. Save it as plannedWork.plannedProjects to plannedWork.results.Change plannedProjects to plannedWork.results.On error
notionFailure to Could not read that Notion database: notionError.message.Set notionFailure to Could not read that Notion database: notionError.message.notionAdvice to Check the id in the 'notionDatabaseId' step, that the database is shared with your Notion connection, and that it has a text property named exactly 'Asana task'..Set notionAdvice to Check the id in the 'notionDatabaseId' step, that the database is shared with your Notion connection, and that it has a text property named exactly 'Asana task'..notionFailure plus notionAdvice.Stop and report a problem: notionFailure plus notionAdvice.createdCount to 0.Set createdCount to 0.projectRow in plannedProjects:For each projectRow in plannedProjects:projectName to blank.Set projectName to blank.titleErrorIf a step below fails, save the error as titleErrorTry
projectRow.title and save it as projectName.Trim projectRow.title and save it as projectName.On error
projectName to blank.Change projectName to blank.projectName is emptyIf projectName is emptyYes
Skipped a row in the Notion database because it has no title, so there is nothing to call the Asana task..Show in the output: Skipped a row in the Notion database because it has no title, so there is nothing to call the Asana task..No
stepsText to blank.Set stepsText to blank.stepsErrorIf a step below fails, save the error as stepsErrorTry
projectRow.properties.Steps and save it as stepsText.Trim projectRow.properties.Steps and save it as stepsText.On error
stepsText to blank.Change stepsText to blank.stepsText with ; replaced by "Split stepsText with ; replaced by
by a new line and save it as stepLines.steps to an empty list.Set steps to an empty list.stepsListed to 0.Set stepsListed to 0.stepLine in stepLines:For each stepLine in stepLines:stepLine and save it as stepName. Trim stepLine and save it as stepName.stepName isn't empty If stepName isn't emptyYes
stepsListed.Add 1 to stepsListed.steps is less than 15If the length of steps is less than 15Yes
stepName to the end of steps and save it as steps.Add stepName to the end of steps and save it as steps.No
No steps
No
No steps
steps is emptyIf steps is emptyYes
No
stepsListed is greater than 15If stepsListed is greater than 15Yes
stepsListed steps; only the first 15 became subtasks. Add the rest in Asana by hand.Show in the output: The Notion row '@projectName' lists stepsListed steps; only the first 15 became subtasks. Add the rest in Asana by hand.No
No steps
dueDate to blank.Set dueDate to blank.dueDateErrorIf a step below fails, save the error as dueDateErrorTry
projectRow.properties["Due date"] and save it as dueValue.Trim projectRow.properties["Due date"] and save it as dueValue.dueValue split by a space split by T and save it as dueDay.Get the first item of the first item of dueValue split by a space split by T and save it as dueDay.dueDay is 10 and dueDay contains -If the length of dueDay is 10 and dueDay contains -Yes
dueDate to dueDay.Change dueDate to dueDay.No
No steps
On error
dueDate to blank.Change dueDate to blank.projectLink to blank.Set projectLink to blank.linkErrorIf a step below fails, save the error as linkErrorTry
projectRow.url and save it as projectLink.Trim projectRow.url and save it as projectLink.On error
projectLink to blank.Change projectLink to blank.taskNotes to Broken out of your Notion planning database..Set taskNotes to Broken out of your Notion planning database..projectLink isn't emptyIf projectLink isn't emptyYes
taskNotes to Broken out of your Notion planning database: projectLink.Change taskNotes to Broken out of your Notion planning database: projectLink.No
No steps
parentTaskId to blank.Set parentTaskId to blank.createErrorIf a step below fails, save the error as createErrorTry
projectName. Save it as createdTask.Create task projectName. Save it as createdTask.
Due date: dueDatetaskNotescreatedTask.gid and save it as parentTaskId.Trim createdTask.gid and save it as parentTaskId.On error
createError.message The row was left unmarked, so it is picked up again on the next run.Show in the output: Could not create the Asana task for the Notion row '@projectName': createError.message The row was left unmarked, so it is picked up again on the next run.parentTaskId isn't emptyIf parentTaskId isn't emptyYes
step in steps:For each step in steps:subtaskError If a step below fails, save the error as subtaskErrorTry
step under task parentTaskId.Create subtask step under task parentTaskId.On error
subtaskFailure to Created the Asana task for '@projectName' but could not add the subtask '@step': subtaskError.message.Set subtaskFailure to Created the Asana task for '@projectName' but could not add the subtask '@step': subtaskError.message.subtaskAdvice to The run stopped there and the Notion row was left unmarked, so this project is built again from scratch on the next run - delete the half-built task in Asana first..Set subtaskAdvice to The run stopped there and the Notion row was left unmarked, so this project is built again from scratch on the next run - delete the half-built task in Asana first..subtaskFailure plus subtaskAdvice.Stop and report a problem: subtaskFailure plus subtaskAdvice.writeBackErrorIf a step below fails, save the error as writeBackErrorTry
projectRow.Update projectRow.createdCount.Add 1 to createdCount.On error
writeBackFailure to Broke the Notion row '@projectName' out into Asana but could not record the task id on that row: writeBackError.message.Set writeBackFailure to Broke the Notion row '@projectName' out into Asana but could not record the task id on that row: writeBackError.message.writeBackAdvice to The run stopped there rather than send the rest of the database across twice. Check that the database has a text property named exactly 'Asana task' that Lodol is allowed to edit..Set writeBackAdvice to The run stopped there rather than send the rest of the database across twice. Check that the database has a text property named exactly 'Asana task' that Lodol is allowed to edit..writeBackFailure plus writeBackAdvice.Stop and report a problem: writeBackFailure plus writeBackAdvice.No
No steps
createdCount planned project(s) out of Notion into Asana tasks with subtasks.Show in the output: Broke createdCount planned project(s) out of Notion into Asana tasks with subtasks.