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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Handling nulls with AD...
Power Automate
Unanswered

Handling nulls with ADO child item count

(0) ShareShare
ReportReport
Posted on by 20
Hi all,
 
I am creating a flow that will populate a "rightsized" field (Yes/No) on ADO depending on if the child item count for a Feature is above/below a certain value.
 
The flow works fine when there are child items but doesn't like when there are no child items, instead just ignoring those items (they should always be populated with "Yes")
 
 
The Parse JSON action has an output like so:
{
  "@odata.context""https://analytics.dev.azure.com/[ORGName]/[ProjectName]/_odata/v3.0-preview/$metadata#WorkItems(WorkItemId,Descendants(Count,DescendantCount))",
  "vsts.warnings@odata.type""#Collection(String)",
  "@vsts.warnings": [
    "VS403508: Using the Parent, Children, Descendants or Revision properties in a filter or expand is not recommended. Details on recommended query patterns are available here: https://go.microsoft.com/fwlink/?linkid=861060."
  ],
  "value": [
    {
      "WorkItemId"1004599,
      "Descendants": []
    }
  ]
}
 
But I can't seem to create a condition where it handles this null/empty value...any tips? (flow attached)
Categories:
I have the same question (0)
  • Mark Nanneman Profile Picture
    991 Super User 2025 Season 2 on at
    I don't ever use ParseJSON personally because it's too much trouble when it comes to dealing with nulls or other variations in the data schema.  You should be able to reference the array of child items directly without using parseJSON.

    I don't know what your flow looks like but assuming "Yes" or True is supposed to be the default in situations where the Rightsized column is blank, you could probably solve this with a coalesce() expression on your Create or Update action. 

    Coalesce goes with the first non-null item in a list of comma seperated items--so whatever the default should be goes at the end.

    It would be something like Coalesce(varRightized, true) where varRightsized is a boolean value and true is the default you want.

    That's a failsafe method, it would be best to fix the condition that drives how you get the Yes or No.  Post a screenshot of this if you could.  Another thing you can do, if you're using a variable to store "yes" or "no" (or True / False) is you can set that variable to the default value you want before your logic is run.  
     
    Hope that makes sense
  • MiDer Profile Picture
    139 on at
    Hey Nick 

    you should let your dummy user vanish ...

    How about one of the following approaches:
    Rather than 
    "expression": {
                                                    "and": [
                                                        {
                                                            "greater": [
                                                                "@items('Apply_to_each_4')?['DescendantCount']",
                                                                "@variables('Rightsize')"
                                                            ]
                                                        },
                                                        {
                                                            "or": [
                                                                {
                                                                    "contains": [
                                                                        "@body('HTTP_2')",
                                                                        "\"Descendants\": []"
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                },
    try 

    @equals(empty(body('http_2')?['Descendants'],true)
    or 

    @equals(body('http_2')?['Descendants']?[0],null)

     
    On a general note, if you just need to evaluate the related item count on the first level the property 'relations' from this URI could do the trick as well:
     
    /_apis/wit/workItems/@{variables('DataObject')?['payload']?['WorkItemBaseID']}?$expand=all

    In case you are interested in certain hierarchy types only, filter them out via select:

    @and(
         equals(
               item()?['rel'], 
               'System.LinkTypes.Hierarchy-Forward'
               ),
         not(
            equals(
                  item()?['attributes']?['Name'],
                  'Parent'
                  )
             )
          )

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard