cancel
Showing results for 
Search instead for 
Did you mean: 

access to assignee parameter in planner Tasks

 
Status: New
Comments
Anonymous
Not applicable
I've figured out a slighty better way to find who the task is assigned to. You don't have to hard code IDs to check against. It'll work for everybody. If Microsoft change how the data is arranged then this will stop working. Use this.
 
substring(string(items('Apply_to_each_2')?['assignments']), 2, 36)
 
Obviously you're going to have to change it to fit your circumstances, but what it does is simple. It takes the assignments objects which contains objects for every user that is assigned to that task. Then it turns it into a string to extract a substring containeing just the user's ID. It's not a solution to give you every assignee, but only the first. Then you can use Get user profile V2.
newmeth.JPG
If you do this, you might want to do some error handling. If there's no assignee and you pass a bunch of strange characters to the user profile action it will get upset and fail your flow. In the end I used parallel branches so that i had a case if it failed and a case if it didn't. 
Advocate II

Hey Josh,

 

Can you show an example where this is not in a loop?

 

If I just have a flow that is trigger when a new planner task is created and I want to read the assigned user, how should that work?

 

I can see from your code the substring( , 2, 36) should return the first user, according to the properties documentation on https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/plannerassignments

 

{
  "ca2a1df2-e36b-4987-9f6b-0ea462f4eb47": null,
  "4e98f8f1-bb03-4015-b8e0-19bb370949d8": { 
      "@odata.type": "microsoft.graph.plannerAssignment",
      "orderHint": "String"
    }
}

But mine returns nothing when trying to implement.

Anonymous
Not applicable

Hi Charles_John,

 

Absolutely. It's almost exactly the same, but you'll get the assignee from the trigger rather than from a list of tasks. 

noloop.JPG

 

 

This is what you're after: 

substring(string(triggerBody()?['assignments']), 2, 36)

 

 

 

I suggest that you set two variables equal to your expression and input, and output them. You'll then be able to see whether your input or your expression is bad. ['assignments'] returns a list of the assignees, so yes, what i wrote will only pull the first assignee from the list.

 

"assignments":


{"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa":{ "@odata.type": "#microsoft.graph.plannerAssignment", "assignedDateTime": "2018-08-02T14:33:09.0383937Z", "orderHint": "", "assignedBy": { "user": { "displayName": null, "id": "bbbbbbbb-bbbb-bbb-bbbb-bbbbbbbbbbbb" } } }, "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa": { "@odata.type": "#microsoft.graph.plannerAssignment", "assignedDateTime": "2018-08-02T14:33:12.8850688Z", "orderHint": "", "assignedBy": { "user": { "displayName": null, "id": "bbbbbbbb-bbbb-bbb-bbbb-bbbbbbbbbbbb" } } }, "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa": { "@odata.type": "#microsoft.graph.plannerAssignment", "assignedDateTime": "2018-08-02T14:33:11.5119427Z", "orderHint": "", "assignedBy": { "user": { "displayName": null, "id": "bbbbbbbb-bbbb-bbb-bbbb-bbbbbbbbbbbb" } }

 

 

I'm not aware of a better way to get any assignee information or even a way to parse the list to extract every assignee. 

 

Good luck!

Advocate II

Got it working! I was incorrectly referring to my "Get_task_details" step and not the "triggerBody".

 

Your solution has also opened my eyes to the world of ms graph API documentation.

https://graph.microsoft.com/v1.0/$metadata#planner/tasks('EnterStringTaskIDhere')/details/$entity

Let's you search through everything.

 

Thank you JoshL

Regular Visitor

 Hi @Anonymous

 

I have tried to apply your string to my flow.

I'd like to simply send a summary email for all actions with due date and assigned owner. I use the List Tasks Action.

I tried your formula and I get thrown an error saying 

"The template validation failed: 'The repetition action(s) 'Apply_to_each_2' referenced by 'inputs' in action 'Get_user_profile_(V2)' are not defined in the template.'."

 

could you take a look and see if you can tell where it fails?

 

 

Flow.PNG

 

 

 

Anonymous
Not applicable

Hi @Adam_N !

 

The problem here is that you're using the expression that's referencing data in a loop called Apply_to_each_2. 

 

The following takes the current item from 'Apply_to_each_2', accesses the assignments object then turns it into a string to finally extract a substring between the second and thirty-sixth character. 

 

substring(string(items('Apply_to_each_2')?['assignments']), 2, 36)

That expression will be inside something like this:

1.JPG

 

First you need to be able to access the specific task that you want. For example, if your task is the trigger then you'll access the assignments using:

 

triggerBody()?['assignments']

You'd then apply your string and substring functions. If you're just pulling it in some other way it will probably look something like:

body('Get_Task')?['assignments']

However, it seems you're trying to build data about each individual task but you're not looping around the tasks and applying your expressions to the individual. List tasks will provide a json of every task. You need to loop over each task to extract the relevant information. Without doing this it would be impossible to determine which 'assignments' you're talking about. Put everything below list tasks into an "apply to each". Then name it something better than what I did. You can then use this:

substring(string(items('Replace with loop name')?['assignments']), 2, 36)

 

 

 

 

Regular Visitor

 @Anonymous

Thanks so much . I already learn a lot.

the loop works to generate the user name for each task in the list.

What i'd like to do now create 1 single HTML table with each individual task listed with the assignee along side.

How can Is it possible for me to do this? I tried within the loop and it doesnt work. 

Thanks so much

Adam

Flow2.PNG

 

Anonymous
Not applicable

@Adam_N

I also would like to create 1 single HTML table with each individual task listed with the assignee name.

Have you already figure out how to do it?

 

Anonymous
Not applicable

@Anonymous

 

I've managed to extract the following data from planner with Flow.

 Planner Tasks In Excel

 

Creating a HTML table with any of that data isn't too difficult. You can this:

 

- Set up variables for each of your desired fields

- Create a string variable we'll use as the table variable and append the start of the table (table opening tag and header row):

 <table> <tr> <th>foo</th> <th>bar</th> </tr> 

- Loop over each task from planner:

        - Set variables equal to that of the tasks fields

        - Append variables from the task as a row to the table variable for instance:

<tr> <td>foo data var</td> <td>bar data var</td> </tr>

- Finally append the closing tag:

</table>

 

You'll now have a string table variable that contains the fully complete HTML table containing task data. It can then be included in emails etc. 

 

Frequent Visitor

Hi,

 

how did you get to Status and URI (link)?

Is Status only described by percentage completed and you converteed the value into "In Progress" or is it given somewhere? I can't find it.