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
But mine returns nothing when trying to implement.
Absolutely. It's almost exactly the same, but you'll get the assignee from the trigger rather than from a list of tasks.
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.
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.
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.
Let's you search through everything.
Thank you JoshL
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?
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:
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:
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:
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)
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
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?
I've managed to extract the following data from planner with Flow.
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:
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.
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.