<?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: Get PortalItem status in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215519#M8791</link>
    <description>&lt;P&gt;Yes, I tried that, but it's still causing an exception right after&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Item curItem = ItemFactory.Instance.Create(curService);
if(LayerFactory.Instance.CanCreateLayerFrom(curItem))
{
    Layer newLayer = LayerFactory.Instance.CreateLayer(new Uri(curService, UriKind.Absolute), activeMapView.Map, 0);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also when trying to show the service as a layer in the Map Viewer at the portal, the error message returned by the viewer is: The layer cannot be added to the map.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Sep 2022 14:51:22 GMT</pubDate>
    <dc:creator>TomGeo</dc:creator>
    <dc:date>2022-09-23T14:51:22Z</dc:date>
    <item>
      <title>Get PortalItem status</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215480#M8789</link>
      <description>&lt;P&gt;I recently experienced that while trying to create a layer from one of our portal services my AGP crashed. Turned out that the service I requested to create the layer from was stopped on the server.&lt;/P&gt;&lt;P&gt;To avoid that, I would like to check on the PortalItem (Item) status, but I do not seem to have the possibility to do so (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9110.html" target="_blank" rel="noopener"&gt;Item Class Members&lt;/A&gt;). Fingers crossed I am only looking at the wrong place.&lt;/P&gt;&lt;P&gt;Can I check the PortalItem status?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 12:49:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215480#M8789</guid>
      <dc:creator>TomGeo</dc:creator>
      <dc:date>2022-09-23T12:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get PortalItem status</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215495#M8790</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Have you tried CanCreateLayer from LayerFactory?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;					if (LayerFactory.Instance.CanCreateLayerFrom(currentItem))
						LayerFactory.Instance.CreateLayer(currentItem, MapView.Active.Map);&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 23 Sep 2022 13:45:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215495#M8790</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-09-23T13:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get PortalItem status</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215519#M8791</link>
      <description>&lt;P&gt;Yes, I tried that, but it's still causing an exception right after&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Item curItem = ItemFactory.Instance.Create(curService);
if(LayerFactory.Instance.CanCreateLayerFrom(curItem))
{
    Layer newLayer = LayerFactory.Instance.CreateLayer(new Uri(curService, UriKind.Absolute), activeMapView.Map, 0);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also when trying to show the service as a layer in the Map Viewer at the portal, the error message returned by the viewer is: The layer cannot be added to the map.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 14:51:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215519#M8791</guid>
      <dc:creator>TomGeo</dc:creator>
      <dc:date>2022-09-23T14:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get PortalItem status</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215617#M8794</link>
      <description>&lt;P&gt;It worked some time ago. So you could place CreateLayer in try/catch block and make return with message on exception:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Item curItem = ItemFactory.Instance.Create(curService);

    try {
    Layer newLayer = LayerFactory.Instance.CreateLayer(new Uri(curService, UriKind.Absolute), activeMapView.Map, 0);
    }
    catch(Exception ex) {
        MessageBox.Show(ex.Message);
        return;
    }&lt;/LI-CODE&gt;&lt;P&gt;It is not elegant way but it works&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 17:27:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-portalitem-status/m-p/1215617#M8794</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-09-23T17:27:25Z</dc:date>
    </item>
  </channel>
</rss>

