<?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: Notebook to check group sharing in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/notebook-to-check-group-sharing/m-p/1400530#M9809</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/131210"&gt;@AFackler_NAPSG&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can use the group ID and then check if the item is shared with the group based off that.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;groupID = 'c901a2470db24abfb92a079f14186c1e'
lyr_item = gis.content.get('db6680d8e14d4f2bba5236752d44efc3')
for group in lyr_item.shared_with['groups']:
    if group.id == groupID:
        print("Shared with group")
    else:
        print("Not shared with group")&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 25 Mar 2024 19:33:59 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2024-03-25T19:33:59Z</dc:date>
    <item>
      <title>Notebook to check group sharing</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/notebook-to-check-group-sharing/m-p/1400523#M9808</link>
      <description>&lt;P&gt;Hey everyone,&lt;/P&gt;&lt;P&gt;I am working on a larger notebook but have ran into a stumbling block. Basically, the end result of the notebook is to check the sharing level of all layers in a webmap and see what layers are shared publicly OR shared to a specific group; in this case, the group is called "NSARGC 3 SARCOP Partnered Collaboration Internal Group - 41484b". I figured out the public sharing part but haven't been able to figure out the group sharing in line 8. For ease of reading, I simplified the script to print "Shared Correctly" or "Not Shared Correctly" since I can get the script to run from there. Does anyone have any ideas on how to look at a specific group? Thanks!&lt;/P&gt;&lt;PRE&gt;wm=WebMap(webmap_item)&lt;BR /&gt;for lyr in wm.layers:&lt;BR /&gt;    if "itemId" in lyr:&lt;BR /&gt;       lyr_item = gis.content.get(lyr.itemId)&lt;BR /&gt;        print(f"Layer {lyr.title} sharing: {lyr_item.shared_with}")&lt;BR /&gt;        if lyr_item.shared_with['everyone'] is True:&lt;BR /&gt;            print("Shared Publicly")&lt;BR /&gt;        if lyr_item.shared_with["NSARGC 3 SARCOP Partnered Collaboration Internal Group - 41484b"] is True:&lt;BR /&gt;            print("Shared to group")&lt;BR /&gt;        else:&lt;BR /&gt;            print("Not Shared Correctly")&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 19:21:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/notebook-to-check-group-sharing/m-p/1400523#M9808</guid>
      <dc:creator>AFackler_NAPSG</dc:creator>
      <dc:date>2024-03-25T19:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook to check group sharing</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/notebook-to-check-group-sharing/m-p/1400530#M9809</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/131210"&gt;@AFackler_NAPSG&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can use the group ID and then check if the item is shared with the group based off that.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;groupID = 'c901a2470db24abfb92a079f14186c1e'
lyr_item = gis.content.get('db6680d8e14d4f2bba5236752d44efc3')
for group in lyr_item.shared_with['groups']:
    if group.id == groupID:
        print("Shared with group")
    else:
        print("Not shared with group")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 25 Mar 2024 19:33:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/notebook-to-check-group-sharing/m-p/1400530#M9809</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-03-25T19:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook to check group sharing</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/notebook-to-check-group-sharing/m-p/1401515#M9813</link>
      <description>&lt;P&gt;Thanks Jack!&lt;/P&gt;&lt;P&gt;I ended up having to modify it a bit to look at layers in the map instead of the map itself, but overall, this solved what I needed!&lt;/P&gt;&lt;P&gt;I ended up needing to append the group ID's into their own list and checking from there since the snippet above would look at each group as a new iteration (at least from what I could tell) and succeed and fail depending on each group. Since all the layers are shared to many groups, it would eventually get to the right group... after "failing" 3 times prior. Maybe this is a roundabout way of doing it, but it works for what I need it to&lt;/P&gt;&lt;PRE&gt;webmap_item = gis.content.get("466b1d08ab8d4dcb9905e7c3a32eba27")&lt;BR /&gt;wm=WebMap(webmap_item)&lt;BR /&gt;groupID = "8e95e3c576304ab49f5fc8396f41484b"&lt;BR /&gt;for lyr in wm.layers:&lt;BR /&gt;    sharedInto = []&lt;BR /&gt;    if "itemId" in lyr:&lt;BR /&gt;        lyr_item = gis.content.get(lyr.itemId)&lt;BR /&gt;        for group in lyr_item.shared_with['groups']:&lt;BR /&gt;            sharedInto.append(group.id)&lt;BR /&gt;        if groupID in sharedInto:&lt;BR /&gt;            print(f"{lyr_item.title} is Shared to group\n")&lt;BR /&gt;        else:&lt;BR /&gt;            print(f"{lyr_item.title} is NOT SHARED\n")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 15:38:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/notebook-to-check-group-sharing/m-p/1401515#M9813</guid>
      <dc:creator>AFackler_NAPSG</dc:creator>
      <dc:date>2024-03-27T15:38:22Z</dc:date>
    </item>
  </channel>
</rss>

