<?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: queryAttachments only returns one attachment when multiple exist in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139789#M76219</link>
    <description>&lt;P&gt;Thanks for the reply Jeff.&amp;nbsp; I'm indexing the return by the oid 3 on purpose.&amp;nbsp; The JSON structure is such that I should be getting an array of attachment objects as the value for the "3" property.&amp;nbsp; Instead I only get one.&lt;/P&gt;&lt;P&gt;I checked the dev console for a counter next to console.log but it's only logging once.&amp;nbsp; It really seems like I'm only getting a single attachment in the response.&lt;/P&gt;&lt;P&gt;For better visibility, I changed the code to log the entire attachmentsByObjectId object.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// get all attachments for feature with objectId = 3
const oid = 3;
const attachmentsByObjectId = await layer.queryAttachments({
    objectIds: [oid]
});

console.log(attachmentsByObjectId);&lt;/LI-CODE&gt;&lt;P&gt;Here is a screenshot of what's logged in the dev console in chrome:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 717px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32931iA77CE0EE625C5CC7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I should be seeing is {3: Array(2)}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Feb 2022 13:16:33 GMT</pubDate>
    <dc:creator>GeoSolver</dc:creator>
    <dc:date>2022-02-02T13:16:33Z</dc:date>
    <item>
      <title>queryAttachments only returns one attachment when multiple exist</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139638#M76199</link>
      <description>&lt;P&gt;I have a feature service with attachments and editing both enabled.&amp;nbsp; Several features have multiple attachments.&amp;nbsp; When I call the queryAttachments() method on this feature layer and pass in an objectId for a feature that has multiple attachments, I only get the first one in the returned data.&lt;/P&gt;&lt;P&gt;This code snippet always returns only the first attachmentInfo but the feature has two attachments.&amp;nbsp; Both attachments are visible in an ArcGIS Online web map that consumes this layer.&amp;nbsp; They are also both visible in the data tab under Content.&amp;nbsp; But again this code only returns the one.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// get all attachments for feature with objectId = 3
const oid = 3;
const attachmentsByObjectId = await layer.queryAttachments({
    objectIds: [oid]
});

if (attachmentsByObjectId &amp;amp;&amp;amp; attachmentsByObjectId[oid] {
    attachmentsByObjectId[oid].forEach(a =&amp;gt; {
        console.log(a);
    });
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Strangely, if I use Postman to query the exact same feature in the same feature service using the /queryAttachments endpoint, I get the correct number of attachments in the response data.&lt;/P&gt;&lt;P&gt;Some info in this URL is obfuscated for privacy, but the rest call works perfectly.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;https://services.arcgis.com/&amp;lt;item&amp;gt;/arcgis/rest/services/&amp;lt;layerName&amp;gt;/FeatureServer/2/queryAttachments&lt;/LI-CODE&gt;&lt;P&gt;And the above call returns the correct data payload including both attachments:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "fields": [
        {
            "name": "OBJECTID",
            "type": "esriFieldTypeOID",
            "alias": "OBJECTID",
            "sqlType": "sqlTypeOther",
            "domain": null,
            "defaultValue": null
        }
    ],
    "attachmentGroups": [
        {
            "parentObjectId": 3,
            "parentGlobalId": "",
            "attachmentInfos": [
                {
                    "id": 1,
                    "name": "test001.jpg",
                    "contentType": "image/jpeg",
                    "size": 3299047,
                    "keywords": "",
                    "exifInfo": null
                },
                {
                    "id": 2,
                    "name": "test002.jpg",
                    "contentType": "image/jpeg",
                    "size": 488852,
                    "keywords": "",
                    "exifInfo": null
                }
            ]
        }
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a problem with my JS code, or is there some arbitrary limitation with the JS API where it will only return a single attachment per feature?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 23:13:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139638#M76199</guid>
      <dc:creator>GeoSolver</dc:creator>
      <dc:date>2022-02-01T23:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: queryAttachments only returns one attachment when multiple exist</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139710#M76211</link>
      <description>&lt;P&gt;You are indexing your return by the oid, 3 in this case in your code that is trying to step through the results: &amp;nbsp;attachmentByObject[3]. &amp;nbsp;Are you parsing the return from your call correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also, console.log(a) may only print once and add a counter how many times it was printed if it’s the same thing. If you are printing results, try console.log(JSON.stringify(a)) for it to print the properties of the object.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 04:53:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139710#M76211</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-02-02T04:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: queryAttachments only returns one attachment when multiple exist</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139789#M76219</link>
      <description>&lt;P&gt;Thanks for the reply Jeff.&amp;nbsp; I'm indexing the return by the oid 3 on purpose.&amp;nbsp; The JSON structure is such that I should be getting an array of attachment objects as the value for the "3" property.&amp;nbsp; Instead I only get one.&lt;/P&gt;&lt;P&gt;I checked the dev console for a counter next to console.log but it's only logging once.&amp;nbsp; It really seems like I'm only getting a single attachment in the response.&lt;/P&gt;&lt;P&gt;For better visibility, I changed the code to log the entire attachmentsByObjectId object.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// get all attachments for feature with objectId = 3
const oid = 3;
const attachmentsByObjectId = await layer.queryAttachments({
    objectIds: [oid]
});

console.log(attachmentsByObjectId);&lt;/LI-CODE&gt;&lt;P&gt;Here is a screenshot of what's logged in the dev console in chrome:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 717px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32931iA77CE0EE625C5CC7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I should be seeing is {3: Array(2)}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 13:16:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139789#M76219</guid>
      <dc:creator>GeoSolver</dc:creator>
      <dc:date>2022-02-02T13:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: queryAttachments only returns one attachment when multiple exist</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139794#M76220</link>
      <description>&lt;P&gt;Out of curiosity I did a quick test with a different feature.&amp;nbsp; I uploaded the exact same two files as attachments to a different feature and it works.&amp;nbsp; Querying attachments on that feature returns both attachments.&lt;/P&gt;&lt;P&gt;So....I went back to the original feature, deleted the attachment that is missing in the query responses, re-uploaded it, and now it works.&amp;nbsp; Both attachments are returning in the query response for the original feature as well.&lt;/P&gt;&lt;P&gt;I must have had a bad upload the first time.&amp;nbsp; Next time I'll experiment with the actual file uploads a bit more before blaming my code.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 13:23:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryattachments-only-returns-one-attachment-when/m-p/1139794#M76220</guid>
      <dc:creator>GeoSolver</dc:creator>
      <dc:date>2022-02-02T13:23:39Z</dc:date>
    </item>
  </channel>
</rss>

