Inside Activate
...
How To
Finding Service Instances Below A Root Path
4 min
overview in activate, service instances can be queried relative to a specific service tree location this allows you to retrieve all service instances, or only those that exist under a defined service root this approach is commonly used in scripts where service instances need to be filtered by structure rather than by individual service names how service root filtering works the services collection exposed on a user supports path based access by passing a service root path, activate returns a serviceinstancecollection containing all matching service instances beneath that path wildcard paths can be used to include all child services example usage the following example demonstrates retrieving all service instances assigned to the current user only service instances under a specific sub tree serviceinstancecollection col1 = currentuser services\["//services/ "] as serviceinstancecollection; serviceinstancecollection col2 = currentuser services\["//services/examples/ "] as serviceinstancecollection; trace writeline($"all service instances count {col1 count}"); trace writeline($"examples service (and child service instances) instances count {col2 count}"); common use cases this pattern is useful when you need to process or report on all services assigned to a user restrict logic to services under a specific folder or category compare service usage across different service branches notes and considerations ensure the path exists in the service tree use wildcards to include child services results are limited to services assigned to the target user