Also looking for this feature to be built-in.
If anyone is interested, this can be achieved using the python API, code snippet below for implementation on a specific project:
# Initialise
api_client = authenticate_asana_client()
tasks_api_instance = asana.TasksApi(api_client)
sections_api = asana.SectionsApi(api_client)
section_id_dict = {'Section name': 'SECTION_ID'} # Lookup IDs for section of interest
project_tasks = get_all_asana_project_tasks()
# Loop though tasks in project
for task in project_tasks:
# Get task ID
task_gid = task["gid"]
# Get all details of task
task_details = tasks_api_instance.get_task(task_gid, {})
# Extract task name
full_task_name = task_details["name"]
# Extract date last modified
last_modified = task_details['modified_at']
last_modified = datetime.datetime.fromisoformat(last_modified.replace("Z", "+00:00"))
# Calculate date 3 months ago
utc = pytz.UTC # Get UTC timezone
three_months_ago = utc.localize(datetime.datetime.utcnow()) - datetime.timedelta(days=3*30)
# Select only tasks not modified in the past 3 months
if last_modified < three_months_ago:
# Loop through projects it is a member of
for project in task_details['memberships']:
# Proceed only for the 'Data Requests' project
if project['project']['name'] == 'Data Requests': # Select Data Requests
section_name = project['section']['name']
section_ID = project['section']['gid']
# If section is request, move to icebox
if section_name == 'Requests':
new_section_name = 'Icebox (Old requests)'
new_section_id = section_id_dict[new_section_name]
move_task_to_section(sections_api, task_details,
new_section_id,new_section_name)
def get_all_asana_project_tasks(
access_token="TOKEN",
project_id="PID",
):
"""
Given asana API access token and a project ID, return all tasks as a list of dicts.
"""
# Configure and authorise asana api
api_client = authenticate_asana_client(access_token)
tasks_api_instance = asana.TasksApi(api_client)
# Get all tasks from project
# Note project ID can be found in its URL
task_response = tasks_api_instance.get_tasks_for_project(project_id, {})
# Convert response into a list
all_tasks = []
for t in task_response:
all_tasks.append(t)
return all_tasks
def move_task_to_section(sections_api, task_details, new_section_id,new_section_name):
"""Move a task to a new section."""
opts = {
'body': {
'data': {
'task': task_details.get('gid')
}
}
}
sections_api.add_task_for_section(new_section_id, opts)
print(f"Moved task: {task_details['name']} to {new_section_name}")