Programmatically attach user object in notes field

I am working on programmatically creating new tasks based on a form submission, and I am including some information about the form submitter in the notes field (technically using html_notes).

I love how, when entering notes manually, you can use @user to directly link a User into the note, but I’m finding that @useremail@email.com remains a string when entered via the API and does not unfurl into the User object.

My attempt so far:

var newTask = {
    data: {
        ...
        html_notes: "<b>Requested by:</b> @" + request.requester;
        ...
    }
}

Is there a way to do this programmatically?

1 Like

You need to enter the link of the user’s My Task list. Unfortunately the id of this list is not the user.id and there is no way to find it out as far as I know. I am waiting for a response on this issue too.

2 Likes

Hey @Daniel_Lusk,

Thanks for reaching out. I’m sorry to report that you’ve uncovered a shortcoming in our API. We hope to add @mentions and MyTasks to the API in the nearish future, though the work hasn’t been scheduled yet.

MyTasks are essentially a project, so the URL for your MyTasks is https://app.asana.com/0/<project-id>

The only somewhat practical workaround I can think of would be to create a project in Asana that maps user info (such as name, id or email) to their MyTasks project id. You could then reference this project via the API when you need to @mention a user.

There’s another possible workaround, however, it’s exceedingly gnarly. You could make GET requests for projects/<user-id +1> and then continue to increment the user-id by one. One of your first successful requests is likely to be the user’s MyTasks as this project is created soon after the user id is created (though you will likely hit their Personal Projects MyTasks first). This method won’t work if a user is added to a workspace after they were already an Asana user.

2 Likes

I’m just adding a note in case anyone comes across this thread going forward; the Asana API team has now added the ability to access and manage a user’s My Tasks list :partying_face: - details are here:

3 Likes