web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Can't get planner task label into SharePoint list

(0) ShareShare
ReportReport
Posted on by 6

I have a manually triggered flow that deletes the items in a SharePoint list.  I am then retrieving all of the tasks on a Planner board using Get task detail and re-creating the SP list.  This flow is used as a starting point to archive Planner tasks into a SP list.  Trouble that I'm having is retrieving the labels.

 

The expression for retrieving the name of the label (I've used this successfully in other flows) is:

if(equals(Outputs('Get_Task_Details')?['body/appliedcategories/Category5'],true), 'Other', if(equals(Outputs('Get_Task_Details')?['body/appliedcategories/Category3'],true), 'Customer Concern', if(equals(Outputs('Get_Task_Details')?['body/appliedcategories/Category2'],true), 'CA', if(equals(Outputs('Get_Task_Details')?['body/appliedcategories/Category4'],true), 'ECR', ''))))

 

The flow will run but the labels field in the SP list does not populate.  What am I missing?

I have the same question (0)
  • Verified answer
    Amit_Sharma Profile Picture
    1,569 Super User 2024 Season 1 on at
    Re: Can't get planner task label into SharePoint list

    Hi @aaronf 

    You are using output of get details action you have to use output of list Taks action because get details does not return category.

    please go with this Expression

     

     

    if(equals(items('Apply_to_each')?['appliedCategories/Category5'],true), 'Other', if(equals(items('Apply_to_each')?['appliedCategories/Category3'],true), 'Customer Concern', if(equals(items('Apply_to_each')?['appliedCategories/Category2'],true), 'CA', if(equals(items('Apply_to_each')?['appliedCategories/Category4'],true), 'ECR', ''))))

     

     

    -------------------------------------------------------------------

    If I have answered your question, please mark post as Solved.
    If you like my response, please give it a Thumbs Up.

  • grantjenkins Profile Picture
    11,059 Moderator on at
    Re: Can't get planner task label into SharePoint list

    Are you able to show what you have in your Create item? Also, what is the column type in your SharePoint List for your Labels (Single line of text, Choice, etc.)?

     

    I've also got a flow that will dynamically retrieve the actual label name rather than having to have your multiple conditions and setting the label names manually. This way if you change the name of a label in your Planner you won't have to update your flow to match.

  • aaronf Profile Picture
    6 on at
    Re: Can't get planner task label into SharePoint list

    Amit_Sharma, that solved my issue, thanks!  In previous trials trying to use List tasks, I believe I had incorrect syntax.

     

    grantjenkins, the label column in the SP is set to choice, but I could easily change that.  I would prefer to have the freedom of using the label name without running through the conditions.

     

    aaronf_0-1671884722712.png

     

  • grantjenkins Profile Picture
    11,059 Moderator on at
    Re: Can't get planner task label into SharePoint list

    Hopefully this will help with getting the label names dynamically. Planner has horrible output when it comes to labels.

     

    For this example, I've got the following Planner tasks.

    grantjenkins_0-1671892210548.png

     

    And my SharePoint List contains the Title and a Multi-select Choice Field since you can add multiple labels to each task.

    grantjenkins_1-1671892286132.png

     

    The full flow is below (excluding your deleting the existing items). I'll go into each of the actions.

    grantjenkins_2-1671892363596.png

     

    List tasks returns all the tasks from my Planner.

    grantjenkins_3-1671892416415.png

     

    Get plan details retrieves the categories (labels) that we have available for our Planner. We will use this to get the actual label names. You could just add the plan Id manually, or what I've done is get the first task and retrieve the plan Id from there. The expression used is:

    first(outputs('List_tasks')?['body/value'])?['planId']

    grantjenkins_5-1671892701339.png

     

    If you look at the body returned, you'll see the categories.

     

    grantjenkins_4-1671892665575.png

     

    XML Plan Categories converts the categoryDescriptions JSON to XML so we can retrieve the values later. The expression used is:

    xml(json(concat('{"root": { value:', outputs('Get_plan_details')?['body/categoryDescriptions'], '}}')))

    grantjenkins_6-1671892945766.png

     

    This will give us the following XML output:

    <root>
     <value>
     <category1>Cool</category1>
     <category2>Nice</category2>
     <category3>Awesome</category3>
     <category4>Amazing</category4>
     <category5>Great</category5>
     </value>
    </root>

     

    Apply to each iterates through each of the tasks from our List tasks.

    grantjenkins_7-1671893005942.png

     

    For each task we use Get a task to get the categories (labels) for the task.

    grantjenkins_8-1671893066387.png

     

    XML Task Categories converts the Task Categories to XML so we can use XPath. The expression used is:

    xml(json(concat('{"root": { value:', outputs('Get_a_task')?['body/appliedCategories'], '}}')))

    grantjenkins_9-1671893154883.png

     

    Select Categories uses XPath to retrieve each of the category labels. The following expressions are used for the input and Value respectively. Note that we need to use Value for the Map name as this will be used to add the label names to our SharePoint List Multi-select Choice field.

    //input
    xpath(outputs('XML_Task_Categories'), '//value/*')
    
    //Value
    xpath(outputs('XML_Plan_Categories'), concat('string(//value/*[name()="', xpath(item(), 'name(//*)'), '"]/text())'))

    grantjenkins_10-1671893291952.png

     

    Filter array Categories removes any categories that were empty. This will happen when someone selects a category that you haven't named in your planner. The expression used here is:

    item()?['Value']

    grantjenkins_11-1671893480900.png

     

    Finally, Create item will add the task to the SharePoint List. Note that the Label field uses the output from the Filter array Categories - and you will need to go into array mode (see arrow on screenshot below).

    grantjenkins_12-1671893591361.png

     

    After running the flow, I get the following items created in my SharePoint List.

    grantjenkins_13-1671893715172.png

     

    The benefit of build the flow to dynamically get the label names is that if you update or add new categories in your Planner you won't need to update your flow as it will automatically pick up the changes.

  • aaronf Profile Picture
    6 on at
    Re: Can't get planner task label into SharePoint list

    Thanks for the tip, I'll give it a try.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 691 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 431 Moderator

#3
developerAJ Profile Picture

developerAJ 266

Last 30 days Overall leaderboard