<?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: Add users to portalgroups like df in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/add-users-to-portalgroups-like-df/m-p/1189190#M7539</link>
    <description>&lt;P&gt;Thank you - it worked!&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jul 2022 16:10:12 GMT</pubDate>
    <dc:creator>mylktea</dc:creator>
    <dc:date>2022-07-04T16:10:12Z</dc:date>
    <item>
      <title>Add users to portalgroups like df</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/add-users-to-portalgroups-like-df/m-p/1178502#M7439</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a df with cl1 and cl2. cl1 displays the group name and cl2 the users which should be added to the group in cl1.&lt;/P&gt;&lt;P&gt;I am trying to loop through the df but got issues when the users should be added to the group.&lt;/P&gt;&lt;P&gt;Also when I leave out the index at groups.add_users(), it gives me the error:&lt;/P&gt;&lt;P&gt;'list' object has no attribute 'add_users'&lt;/P&gt;&lt;LI-CODE lang="c"&gt;for i in df['c1']:
    groups = gis.groups.search('title: "'+i+'"', '')
    print(groups)

for row in df['c2']:
    for i in groups:
        groups[i].add_users(row)&lt;/LI-CODE&gt;&lt;P&gt;e.g.:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;cl1&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;cl2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;group_xy&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;user_1, user_2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;group_b&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;user_3, user_4, user_5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I forgetting something?&amp;nbsp;&lt;SPAN&gt;Would be very grateful if anyone know of a solution or what I am doing wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 11:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/add-users-to-portalgroups-like-df/m-p/1178502#M7439</guid>
      <dc:creator>mylktea</dc:creator>
      <dc:date>2022-05-31T11:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Add users to portalgroups like df</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/add-users-to-portalgroups-like-df/m-p/1187772#M7527</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/559095"&gt;@mylktea&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will add the users in cl2 to the groups in cl1&lt;/P&gt;&lt;LI-CODE lang="python"&gt;group_lst = df["cl1"].tolist()

## for each group name in the list
for group in group_lst:
    ## get the string content of cl2 cell
    users = df.loc[df['cl1'] == group, 'cl2'].iloc[0]
    ## remove any spaces (this is to remove the space after each 
    ## comma in your cl2) omit the .replace if your usernames contain spaces
    ## easier to make sure the usernames in cl2 follow 
    ## User_1,User_2,User_3 with no spaces in the text
    ## the .split creates the list to add users
    users = users.replace(" ", "").split(",")
    add2group = portal.groups.search(group)[0]
    ## by printing you will given a dictionary of any failures to add
    print(add2group.add_users(users))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Jun 2022 13:52:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/add-users-to-portalgroups-like-df/m-p/1187772#M7527</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2022-06-29T13:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Add users to portalgroups like df</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/add-users-to-portalgroups-like-df/m-p/1189190#M7539</link>
      <description>&lt;P&gt;Thank you - it worked!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 16:10:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/add-users-to-portalgroups-like-df/m-p/1189190#M7539</guid>
      <dc:creator>mylktea</dc:creator>
      <dc:date>2022-07-04T16:10:12Z</dc:date>
    </item>
  </channel>
</rss>

