Comment
Kilo Sage

I don't use user criteria all that often - but when I do I always come back to this post. Thanks a lot for this!

 

Some additions:

The API shown in this post is made available via the plugin: com.glideapp.user_criteria.scoped.api

Before using the API in a script, a caller should first test if this plugin is installed:

new GlidePluginManager().isActive('com.glideapp.user_criteria.scoped.api')