<?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: attribute rule attachment table: expected attachment type arcade error in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-attachment-table-expected/m-p/1370186#M77414</link>
    <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/419419"&gt;@geopamplona&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a post from a while back that somewhat matches what you have: &lt;A href="https://community.esri.com/t5/arcgis-online-questions/arcade-count-attachments-in-related-table/td-p/1116720" target="_blank"&gt;https://community.esri.com/t5/arcgis-online-questions/arcade-count-attachments-in-related-table/td-p/1116720&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I was curious if you could try to do:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    var features = FeatureSetByName($datastore,'FeatureClass', ['*'], false);
    var gid=$feature.REL_GLOBALID;
    var item=First(Filter(features, 'globalid = @gid'));
    var cnt = 0
    for(var item in features) {
        cnt += Count(Attachments(item))
    }
    if ($editcontext.editType == 'DELETE'){
    var count_total=cnt-1
    } else {
    var count_total=cnt
    }

    return {
    'edit': [{
    'classname' : 'FeatureClass',
    'updates' : [{
    'globalid': gid,
    'attributes' : {'Adjs' :count_total }
    }]
    }]
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is just a rough rendition so I hope it can provide some help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jan 2024 15:37:35 GMT</pubDate>
    <dc:creator>CodyPatterson</dc:creator>
    <dc:date>2024-01-15T15:37:35Z</dc:date>
    <item>
      <title>attribute rule attachment table: expected attachment type arcade error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-attachment-table-expected/m-p/1370180#M77412</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am using arcade code to count attachments and save in field, but&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Count(Attachments(item));&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;but I get the following error:&lt;BR /&gt;invalid arcade expression, arcade error: expected attachment type, script line: 4&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="geopamplona_0-1705332358982.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91611iB57D315E2B256126/image-size/medium?v=v2&amp;amp;px=400" role="button" title="geopamplona_0-1705332358982.png" alt="geopamplona_0-1705332358982.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm using ArCGIS pro 2.9.11 and enterprise 2.9.1&lt;/P&gt;&lt;P&gt;My attribute rule:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;var features = FeatureSetByName($datastore,'FeatureClass', ['*'], false);&lt;BR /&gt;var gid=$feature.REL_GLOBALID;&lt;BR /&gt;var item=First(Filter(features, 'globalid = @gid'));&lt;BR /&gt;var count = Count(Attachments(item));&lt;BR /&gt;if ($editcontext.editType == 'DELETE'){&lt;BR /&gt;var count_total=count-1&lt;BR /&gt;} else {&lt;BR /&gt;var count_total=count&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return {&lt;BR /&gt;'edit': [{&lt;BR /&gt;'classname' : 'FeatureClass',&lt;BR /&gt;'updates' : [{&lt;BR /&gt;'globalid': gid,&lt;BR /&gt;'attributes' : {'Adjs' :count_total }&lt;BR /&gt;}]&lt;BR /&gt;}]&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have tried the same Count(Attachments()) line and it is valid arcade for calculated fields.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 15:29:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-attachment-table-expected/m-p/1370180#M77412</guid>
      <dc:creator>geopamplona</dc:creator>
      <dc:date>2024-01-15T15:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: attribute rule attachment table: expected attachment type arcade error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-attachment-table-expected/m-p/1370186#M77414</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/419419"&gt;@geopamplona&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a post from a while back that somewhat matches what you have: &lt;A href="https://community.esri.com/t5/arcgis-online-questions/arcade-count-attachments-in-related-table/td-p/1116720" target="_blank"&gt;https://community.esri.com/t5/arcgis-online-questions/arcade-count-attachments-in-related-table/td-p/1116720&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I was curious if you could try to do:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    var features = FeatureSetByName($datastore,'FeatureClass', ['*'], false);
    var gid=$feature.REL_GLOBALID;
    var item=First(Filter(features, 'globalid = @gid'));
    var cnt = 0
    for(var item in features) {
        cnt += Count(Attachments(item))
    }
    if ($editcontext.editType == 'DELETE'){
    var count_total=cnt-1
    } else {
    var count_total=cnt
    }

    return {
    'edit': [{
    'classname' : 'FeatureClass',
    'updates' : [{
    'globalid': gid,
    'attributes' : {'Adjs' :count_total }
    }]
    }]
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is just a rough rendition so I hope it can provide some help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 15:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-attachment-table-expected/m-p/1370186#M77414</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-01-15T15:37:35Z</dc:date>
    </item>
  </channel>
</rss>

