<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to update/reset users.categories in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1379171#M9631</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is there a way to reset the&amp;nbsp;&lt;SPAN class=""&gt;gis&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;users&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;categories? Or update / remove specific entries in the memberCategorySchema?&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis.users.categories = None&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN class=""&gt;will delet all the user-categories, but reloading a memberCategorySchema will fail afterwards.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis.users.categories = {'memberCategorySchema': [
{'title': 'Categories','categories': [{'title': 'bla','categories': [{'title': 'bli','categories': [{'title': 'blu'}]}]}]}]}&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;self._gis.users.categories[0]["categories"]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IndexError: list index out of range&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2024 16:27:34 GMT</pubDate>
    <dc:creator>AndreasEugster</dc:creator>
    <dc:date>2024-02-07T16:27:34Z</dc:date>
    <item>
      <title>How to update/reset users.categories</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1379171#M9631</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is there a way to reset the&amp;nbsp;&lt;SPAN class=""&gt;gis&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;users&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;categories? Or update / remove specific entries in the memberCategorySchema?&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis.users.categories = None&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN class=""&gt;will delet all the user-categories, but reloading a memberCategorySchema will fail afterwards.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis.users.categories = {'memberCategorySchema': [
{'title': 'Categories','categories': [{'title': 'bla','categories': [{'title': 'bli','categories': [{'title': 'blu'}]}]}]}]}&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;self._gis.users.categories[0]["categories"]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IndexError: list index out of range&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 16:27:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1379171#M9631</guid>
      <dc:creator>AndreasEugster</dc:creator>
      <dc:date>2024-02-07T16:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to update/reset users.categories</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1379228#M9632</link>
      <description>&lt;P&gt;Hey Andreas have you tried using gis.content.categories.delete()?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#categoryschemamanager:~:text=The%20delete%20function%20allows%20group%20owner%20or%20managers%20to%20remove%20the%20category%20schema%20set%20on%20a%20group." target="_self"&gt;documentation&lt;/A&gt; you may need to fully remove the the category schema, remake and reassign this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 17:16:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1379228#M9632</guid>
      <dc:creator>David_McRitchie</dc:creator>
      <dc:date>2024-02-07T17:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to update/reset users.categories</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1379546#M9634</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;BR /&gt;Your answer refers to &lt;STRONG&gt;content&lt;/STRONG&gt;-categories... I'm talking about &lt;STRONG&gt;user&lt;/STRONG&gt;-categories and the "&lt;SPAN&gt;&lt;STRONG&gt;member&lt;/STRONG&gt;CategorySchema".&amp;nbsp;There is no gis.users.categories.delete()...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 08:09:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1379546#M9634</guid>
      <dc:creator>AndreasEugster</dc:creator>
      <dc:date>2024-02-08T08:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to update/reset users.categories</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1380204#M9639</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/116068"&gt;@AndreasEugster&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using arcgis api version 2.2.0.1 and I have no issue with the following.&lt;/P&gt;&lt;P&gt;Create a user category schema&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

agol = GIS("home")

user_schema = {
    "memberCategorySchema": [
        {
            "title": "Office Location",
            "categories": [
                {
                    "title": "USA",
                    "categories": [
                        {
                            "title": "Maine"
                        },
                        {
                            "title": "California",
                            "categories": [
                                {
                                    "title": "Redlands"
                                },
                                {
                                    "title": "San Diego"
                                }
                            ]
                        }
                    ]
                },
                {
                    "title": "Europe",
                    "categories": [
                        {
                            "title": "Zurich"
                        },
                        {
                            "title": "Edinburgh"
                        }
                    ]
                }
            ]
        },
        {
        "title": "Department",
        "categories": [
            {
                "title": "Sales"
            },
            {
                "title": "Consulting"
            }
        ]
    }
    ]
}

agol.users.categories = user_schema&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Print to test... I wont add results put it prints fine&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

agol = GIS("home")

print(agol.users.categories)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Delete the schema&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

agol = GIS("home")

agol.users.categories = None&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Re-print, it returns None.&lt;/P&gt;&lt;P&gt;Re-assign a new schema.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

agol = GIS("home")

user_schema = {
    'memberCategorySchema': [
        {
            'title': 'Categories',
            'categories': [
                {
                    'title': 'bla',
                    'categories': [
                        {
                            'title': 'bli',
                            'categories': [
                                {
                                    'title': 'blu'
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

agol.users.categories = user_schema&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Printing new schema works just fine.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

agol = GIS("home")

print(agol.users.categories[0]["categories"])

##prints
[{'title': 'bla', 'categories': [{'title': 'bli', 'categories': [{'title': 'blu'}]}]}]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 08:32:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1380204#M9639</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2024-02-09T08:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to update/reset users.categories</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1380230#M9640</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Strange... Can you confirm that the snippet works if you re-assign the schema directly after setting it None without "reconnecting" to GIS("home")?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

agol = GIS("home")
agol.users.categories = None

user_schema = {
    'memberCategorySchema': [
        {
            'title': 'Categories',
            'categories': [
                {
                    'title': 'bla',
                    'categories': [
                        {
                            'title': 'bli',
                            'categories': [
                                {
                                    'title': 'blu'
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

agol.users.categories = user_schema
## results in error?!
## however with "reconnecting before re-assigning" it works:
# agol = GIS("home")
# agol.users.categories = user_schema&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;why the "re-connection"?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 10:05:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1380230#M9640</guid>
      <dc:creator>AndreasEugster</dc:creator>
      <dc:date>2024-02-09T10:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to update/reset users.categories</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1380442#M9641</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/116068"&gt;@AndreasEugster&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What error are you getting? It it this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ValueError: A list or tuple must be given to set the categories.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error if the categories is already set to None. Worked around it with the below.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

agol = GIS("home")

## only update to None if it is not already None
if agol.users.categories != None:
    agol.users.categories = None


user_schema = {
    'memberCategorySchema': [
        {
            'title': 'Categories',
            'categories': [
                {
                    'title': 'bla',
                    'categories': [
                        {
                            'title': 'bli',
                            'categories': [
                                {
                                    'title': 'blu'
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}


agol.users.categories = user_schema

print(agol.users.categories)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 17:10:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1380442#M9641</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2024-02-09T17:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to update/reset users.categories</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1381461#M9650</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As soon as the users.categories are None I can not reasign the schema anymore... unless I'm reconnecting to agol once more (agol = GIS("home")) before asigning the schema. Doing it in one run without reconnecting results in the error: ...&lt;EM&gt;in categories&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;for category in self._gis.users.categories[0]["categories"]:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IndexError: list index out of range&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I'll try with the latest&amp;nbsp;&lt;SPAN&gt;arcgis api version 2.2.x (rigthnow using 2.1.x) and also outside our internal-network. I'll provide an update later&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 07:34:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1381461#M9650</guid>
      <dc:creator>AndreasEugster</dc:creator>
      <dc:date>2024-02-13T07:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to update/reset users.categories</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1382052#M9654</link>
      <description>&lt;P&gt;Seems to work with 2.2.0.x&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;BR /&gt;Did not check if internal-network or 2.1.x was the issue tho.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 08:18:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-update-reset-users-categories/m-p/1382052#M9654</guid>
      <dc:creator>AndreasEugster</dc:creator>
      <dc:date>2024-02-14T08:18:24Z</dc:date>
    </item>
  </channel>
</rss>

