cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kdavis91
Continued Contributor
Continued Contributor

Syntax for Pulling Data from Body Best Practices

Hello,

 

This is not so much a request for a solution as it is a request for best practice.

 

I was trying to pull the 'Completedby' parameter from each task in a loop iterating through List Tasks. In another thread, @HonzaUH was nice enough to provide the syntax for pulling data out of a Trigger using the expression:

 

triggerBody()?['completedBy']?['user']?['ID']

 

which worked great when I was pulling the data from the trigger "When a Task is Marked Complete".

 

However, since it doesn't work when the output I want is not from a trigger, I have tried a number of expressions namely the Items() expression, as the tooltip text suggests that it is used while in a 'for each' loop. I used the expression:

 

items('Apply to each 2')?['completedBy']?['user']?['ID']

 

Which successfully returned the UserID of the individual who completed the task. So that solved my immediate problem.

 

I am mostly looking for some guidance on using these expressions. I am not familiar (yet) with JSON (assuming this is JSON) syntax. Is this the best way to be accessing this data? While I certainly don't mind learning as I go--including stumbling around in the dark for a while looking for the solution--I would like to also learn efficiencies and best practices, drawing on the expertise in this community.

 

I appreciate any tips and input in advance and thank all of you who have contributed already to this community, as I have already read a multitude of threads covering diverse topics and have gleaned quite a bit of information from them.

 

Thanks,

Kyle

3 REPLIES 3
efialttes
Super User III
Super User III

Hi!

"triggerBody()?['completedBy']?['user']?['ID']

which worked great when I was pulling the data from the trigger "When a Task is Marked Complete".

However, since it doesn't work when the output I want is not from a trigger"

 

Which action block are you dealing with? Get a task?

If so, and assuming the name of the action block is the default one (Get a task), my suggestion is to try with the following expression:

body('Get_a_Task')?['completedBy']?['user']?['ID']

 

BTW, quite interested in this 'completedBy' field, since I do not remember such field to be shown in the Dynamic Contents menu. I heard of other hidden Planner task fields -total number of checklists per Task, total number of active checklists per Task, label numbers, what is selected to be shown on the card (Description, Checklists, Attachments etc)- in this other thread

https://powerusers.microsoft.com/t5/Building-Flows/List-Tasks-Planner-Successful-Alternative-to-get-...

 

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



kdavis91
Continued Contributor
Continued Contributor

Hello!

 

"Which action block are you dealing with? Get a task?"

I am iterating through an "Apply to Each" loop working on a "List Tasks" from Planner.

 

Correct me if I'm wrong, but the expression you suggest only looks at the body of a single task as the "Get a Task" action only returns one task. My flow is going through a list of all the tasks in a plan (then checks to make sure it only acts on tasks in a certain bucket). I think I had originally tried the "body()" expression, but (again, if I am understanding it correctly) the problem was that the body of "List Tasks" is all of the tasks in the plan; and I want to get the "completedBy UserID" for the task that the loop is currently on.

 

The purpose of my Flow is to update an Excel Spreadsheet that already has a list of the tasks from a certain bucket and update each row with the completed datetime and the Display Name of the user who marked it complete. See Screenshot. I haven't finished building it, but it's almost there. The condition is checking to make sure that the BucketID of the current task in the Loop matches the BucketID of the Bucket whose tasks I want.

Get Completed By Planner.png

"BTW, quite interested in this 'completedBy' field, since I do not remember such field to be shown in the Dynamic Contents menu"

You would think it should be, but, you're right, it isn't. But it is in the body of the Planner Task. And it is accessible via Expressions Again, shoutout to @HonzaUH for that nugget! Just looking at the body of a Planner Task shows several fields that are there but not linked by Dynamic Content.

 

HonzaUH
Advocate I
Advocate I

Hi @kdavis91 !

Hope everything except that misserable Flow problem is perfectly fine with you 🙂

 

I went through it and honestly I don't see any other way to do what you did. So to answer your question, when it comes to Flow any way that works is the best way! But as I mentioned to you previously, I am also just beggining with Flow so it is hard for me to say, if a better way exists. Maybe we get an experts opinion if we wait.

 

Suggestions anybody? 

Keep up the good work Kyle!

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (76,477)