Get Creator Users per group

342
3
Jump to solution
04-16-2020 02:13 PM
JeffTimm
Occasional Contributor

I am struggling with getting all of the creators in a certain group in my Enterprise portal environment.

I am using Enterprise Notebook.

group = gis.groups.get("6bde3136acbb48bcba1edc2eca61eac6")
response = group.get_members()
for user in response['users'] :
print(user)

will list all the users in specified group, but how do I limit it further to only Creators?

0 Kudos
1 Solution

Accepted Solutions
BenTurrell
Occasional Contributor III

Hey Jeff Timm‌,

So I just checked the API and the group.get_memebers() returns an array of usernames and not user objects like I thought it would. I think if you change it to something like this you will have some better luck:

group = gis.groups.get("6bde3136acbb48bcba1edc2eca61eac6")
response = group.get_members()
for username in response['users'] :

   user = gis.users.get(username)
   if(user.userLicenseTypeId == "creatorUT"):

      print(user)

View solution in original post

3 Replies
BenTurrell
Occasional Contributor III

Hey Jeff Timm‌,

You can print out the creators using something like so:

group = gis.groups.get("6bde3136acbb48bcba1edc2eca61eac6")
response = group.get_members()
for user in response['users'] :
   if(user.userLicenseTypeId == "creatorUT"):

      print(user)

Let me know if you have any issues with the above.

Thanks,

Ben


If this answer was helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.

JeffTimm
Occasional Contributor

I still get an error.  I tried something similar to what you proposed.  It is the user type that I have issues with.

---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)<ipython-input-2-8fcaf853ac6d> in <module>      2 response = group.get_members()      3 for user in response['users'] :----> 4    if(user.userLicenseTypeId == "creatorUT"):      5       print(user)AttributeError: 'str' object has no attribute 'userLicenseTypeId'
0 Kudos
BenTurrell
Occasional Contributor III

Hey Jeff Timm‌,

So I just checked the API and the group.get_memebers() returns an array of usernames and not user objects like I thought it would. I think if you change it to something like this you will have some better luck:

group = gis.groups.get("6bde3136acbb48bcba1edc2eca61eac6")
response = group.get_members()
for username in response['users'] :

   user = gis.users.get(username)
   if(user.userLicenseTypeId == "creatorUT"):

      print(user)

View solution in original post