<?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 Re: Getting stuck adding users to groups with python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/getting-stuck-adding-users-to-groups-with-python/m-p/1374640#M69730</link>
    <description>&lt;P&gt;The results of the search operation is a list or results. When you did:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;grouping = gis.groups.search('title: group1')
grouping[0].add_users(list1)&lt;/LI-CODE&gt;&lt;P&gt;You're using the add_users function of the first (index 0) object in the grouping list.&lt;BR /&gt;&lt;BR /&gt;What you have to do, is then iterate over all the elements on the results list and use the add_users function on each of the objects of the list.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import *
gis = GIS("url", "username", "password")
list1 = ['AdvancedUser', 'DefaultUser']
grouping = gis.groups.search('title: group1', 'title: group2')
for grp in grouping:
    grp.add_users(list1)&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 25 Jan 2024 20:24:58 GMT</pubDate>
    <dc:creator>Raul</dc:creator>
    <dc:date>2024-01-25T20:24:58Z</dc:date>
    <item>
      <title>Getting stuck adding users to groups with python</title>
      <link>https://community.esri.com/t5/python-questions/getting-stuck-adding-users-to-groups-with-python/m-p/1374624#M69729</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;I am trying to use a very simple python script to add users to a group and am getting stuck. It works successfully with one group but when I add more I get errors. Here is my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import *
gis = GIS("url", "username", "password")
list1 = ['AdvancedUser', 'DefaultUser']
grouping = gis.groups.search('title: group1')
grouping[0].add_users(list1)&lt;/LI-CODE&gt;&lt;P&gt;When I try with multiple groups here:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import *
gis = GIS("url", "username", "password")
list1 = ['AdvancedUser', 'DefaultUser']
grouping = gis.groups.search('title: group1', 'title: group2')
grouping.add_users(list1)&lt;/LI-CODE&gt;&lt;P&gt;I get the error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 5, in &amp;lt;module&amp;gt;
AttributeError: 'list' object has no attribute 'add_users'&lt;/LI-CODE&gt;&lt;P&gt;Thank you for any help you can provide.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 19:55:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-stuck-adding-users-to-groups-with-python/m-p/1374624#M69729</guid>
      <dc:creator>chill_gis_dude</dc:creator>
      <dc:date>2024-01-25T19:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Getting stuck adding users to groups with python</title>
      <link>https://community.esri.com/t5/python-questions/getting-stuck-adding-users-to-groups-with-python/m-p/1374640#M69730</link>
      <description>&lt;P&gt;The results of the search operation is a list or results. When you did:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;grouping = gis.groups.search('title: group1')
grouping[0].add_users(list1)&lt;/LI-CODE&gt;&lt;P&gt;You're using the add_users function of the first (index 0) object in the grouping list.&lt;BR /&gt;&lt;BR /&gt;What you have to do, is then iterate over all the elements on the results list and use the add_users function on each of the objects of the list.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import *
gis = GIS("url", "username", "password")
list1 = ['AdvancedUser', 'DefaultUser']
grouping = gis.groups.search('title: group1', 'title: group2')
for grp in grouping:
    grp.add_users(list1)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 25 Jan 2024 20:24:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-stuck-adding-users-to-groups-with-python/m-p/1374640#M69730</guid>
      <dc:creator>Raul</dc:creator>
      <dc:date>2024-01-25T20:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Getting stuck adding users to groups with python</title>
      <link>https://community.esri.com/t5/python-questions/getting-stuck-adding-users-to-groups-with-python/m-p/1375100#M69737</link>
      <description>&lt;P&gt;Thank you Raul! I was seriously I was overthinking it. This really helps.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 21:14:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-stuck-adding-users-to-groups-with-python/m-p/1375100#M69737</guid>
      <dc:creator>chill_gis_dude</dc:creator>
      <dc:date>2024-01-26T21:14:47Z</dc:date>
    </item>
  </channel>
</rss>

