Dynamically recursively get all group children from specific (non-root) group?

Is there an OOTB way to return a list of all sub-groups recursively (like the IncludeAllSubGroups parameter from core_v2_group) while setting the starting group using the ParentGroupId parameter (or another parameter) or would I need to write my own function to iterate through each sub-group replacing the ParentGroupId in the List method?

In my testing I haven't had any success with combining the two parameters and not defining a starting group yields all groups and sub-groups on the site (expectedly as it doesn't seem to be context aware of where the method was called).

End Goal: A group list widget that dynamically lists all of the children/grandchildren/etc. of the group containing the widget and is permission aware to not list groups for which the user doesn't have permissions to see.

  • ParentGroupId and IncludeAllSubGroups should work in tandem with each other. The user view permissions issue will be handled without you needing to specify anything in the call, as the query takes into account the accessing user making the call when determining what results to return.

  • This doesn't seem to be working for me. Here is the relevant code that I'm trying:

    #set($group = false)
    	#set($selGroup = false)
        #set($group = $core_v2_utility.ParseInt($core_v2_page.ParseQueryString($core_v2_widget.GetCustomValue('groupSelect', '')).Value('Group')))
        #if ($group > 0)
        	#set($selGroup = $group)
        	#set ($selGroup = $core_v2_group.Current.Id)
        #set ($showSubGroups = true)
    	#set($query = "%{ParentGroupId=$selGroup,IncludeSubGroups='$showSubGroups',PageSize=$pageSize,PageIndex=$pageIndex,SortBy='$sortBy',SortOrder='$sortOrder',GroupTypes='all'}")

    The parent group selection is working, just not the recursive children portion.

  • The property name is IncludeAllSubGroups, not IncludeSubGroups. Since the property isn't correct it's just using the default behavior of returning immediate subgroups, not nested, when a parent group is specified.

  • Sure, don't typo the property and it works just fine!

    Doh! Thanks!