Hello there!
I'm struggling a bit to get a kind of weird flow up and running. I just joined a team and I'm trying to create a condition where Planner tasks that have an applied category (called labels in the Planner UI) where the category description text contains the word "Change" are cloned to another Planner board. Matching the category description as opposed to the color or the category number is key, because there are many planner boards, and everyone chose a different category for tracking Changes that need to be approved by CAB.
Here's where I'm at:
- I initialize an array value called plan_categoryDescriptions
- I use a Get plan details (preview) step to get the category descriptions from the plan
- I use a Set variable step for plan_categoryDescriptions to convert the Category descriptions Dynamic content from the previous step into an array (they are returned JSON objects so I kept getting errors trying to use a Apply to each step)
This is where I get lost - I want to read each of the properties in the array to see if any of the category descriptions contain the word "Change" using an Apply to each step but it keeps consuming the entire array in a single step instead of going line by line. I proved this out by completing the Apply to each step with a condition to write the Properties to a OneNote. Instead of getting multiple lines for each property, I get one big line. What am I doing wrong? Is it in the step where I convert the Category descriptions objects into an array?
Hi @dhansell
You could get the category number by using the below expression:
xpath(xml(json(concat('{"root": { value:',outputs('Get_plan_details')?['body/categoryDescriptions'], '}}'))), concat('name(//root/value/*[contains(text(),','''','Change','''',')])'))
If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.
Thanks
OK, I've run into another problem. Once I've determined which categoryDescription contains the word "Change", I want to return that category number (e.g., category1) so I can compare it against a created Planner Task's appliedCategories.
How the heck do I capture the key that matches the description so I can Apply to each on the Task's appliedCategories to see if it's $true?
@ManishSolanki - this worked perfectly! Thank you so much for helping out a noobus - I don't have much experience with writing expressions so this will help me with other tasks in the future, too. Really appreciate you.
Hi @dhansell
To convert task categories to array, you need to write an expression in the set variable action. Pls set the value of variable as:
xpath(xml(json(concat('{"Root":{"Item":',outputs('Get_plan_details')?['body/categoryDescriptions'],'}}'))),'//text()')
You will get the array of categories in variable.
If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.
Thanks
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional