Change a users licence type to Field worker

767
6
Jump to solution
05-27-2021 09:10 AM
StuartMoore
Occasional Contributor III

i am trying to change a set of users licence in AGOL from Creator to Field Worker

this is what i have but it dosent seem to work (no error or anything)

from arcgis.gis import GIS
gis = GIS("home")
source_users = gis.users.search(query="username:xxx")
for user in source_users:
    print(user.username)
    print(user.userLicenseTypeId)     
    user.userLicenseTypeId = 'fieldWorkerUT'
    print(user.userLicenseTypeId)  
Tags (1)
0 Kudos
2 Solutions

Accepted Solutions
HamishMorton
Esri Contributor

Hi Stuart,

Can you try the following? It is documented here in the API guide.

from arcgis.gis import GIS

gis = GIS("home")

source_users = gis.users.search(query="username:xxx")

for user in source_users:
    
    print(user.username, user.userLicenseTypeId)
    
    user.update_license_type("fieldWorkerUT")
    
    print(user.username, user.userLicenseTypeId)

 

Note that for the update to be successful, the user must have a compatable role.

 

Best,

Hamish

Hamish

View solution in original post

MichaelKellyTeck
Occasional Contributor

Hey Stuart - you need to use the update_license_type method - example here: https://community.esri.com/t5/education-blog/creator-to-gis-professional-advanced-user-type-for-educ...

License type ID's can be found here: https://developers.arcgis.com/rest/enterprise-administration/portal/create-user.htm. Current options include the following: creatorUT | editorUT | GISProfessionalAdvUT | GISProfessionalBasicUT | GISProfessionalStdUT | viewerUT | fieldWorkerUT.

View solution in original post

6 Replies
HamishMorton
Esri Contributor

Hi Stuart,

Can you try the following? It is documented here in the API guide.

from arcgis.gis import GIS

gis = GIS("home")

source_users = gis.users.search(query="username:xxx")

for user in source_users:
    
    print(user.username, user.userLicenseTypeId)
    
    user.update_license_type("fieldWorkerUT")
    
    print(user.username, user.userLicenseTypeId)

 

Note that for the update to be successful, the user must have a compatable role.

 

Best,

Hamish

Hamish
MichaelKellyTeck
Occasional Contributor

Hey Stuart - you need to use the update_license_type method - example here: https://community.esri.com/t5/education-blog/creator-to-gis-professional-advanced-user-type-for-educ...

License type ID's can be found here: https://developers.arcgis.com/rest/enterprise-administration/portal/create-user.htm. Current options include the following: creatorUT | editorUT | GISProfessionalAdvUT | GISProfessionalBasicUT | GISProfessionalStdUT | viewerUT | fieldWorkerUT.

StuartMoore
Occasional Contributor III

thanks both that worked a treat

0 Kudos
EloyBonillaPerez
New Contributor II

Hi,

this is not working for me. The very simple piece of code I am using is:

# _user = p_gis.users.get(username='U19452')
_listUsers = gis.users.search(query='username:{}'.format('U19452'))
for _user in _listUsers:
print(_user.username, _user.userLicenseTypeId)
_user.update_license_type("fieldWorkerUT")
print(_user.username, _user.userLicenseTypeId)

and this is the result:

U19452 creatorUT
U19452 creatorUT

What am I missing?, because it seems quite straightforward.

Thanks in advance for your time.

0 Kudos
StuartMoore
Occasional Contributor III

Hi, i think i had a similar issue if the user was the owner of content it wouldn't change the licence, maybe try changing their account manually to see if you get an error

Stu

EloyBonillaPerez
New Contributor II

Hi Stuart,

you are right. I a user owns any content then you cannot change his type. I think a least you should receive any kind of message informing about this, but the sentence finishes ok.

Thank you very much!!!

0 Kudos