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)
Solved! Go to Solution.
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
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.
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
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.
thanks both that worked a treat
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.
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
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!!!