Filter based on "Photo and Files" in AGOL

1357
4
06-15-2017 04:51 AM
PanGIS
by
Regular Contributor

Hi,

I have published a Feature Service being used in AGOL Map and consumed on Collector.

The attachments are enabled and it is possible to take pictures. We need a picture for each point on the map.

Since there are many points without pictures, in order to speed up the work of our guys on the field, I would like to create a filter that shows only the feature without a picture and once you take it, they will disappear.

Even though you see the field "Photo and Files" in the table of attribute of AGOL it doesn't appear as a field that can be selected when you create a filter.

Is there a way I can filter with a "has attachment" : true/false yes/not?

Thanks.

4 Replies
AdrianWelsh
MVP Notable Contributor

This is a good question and not sure how to best answer it. Maybe it would be a good idea to loop in the https://community.esri.com/community/gis/applications/collector-for-arcgis?sr=search&searchId=09b387...‌ group with this thread since you're using both AGOL and Collector. (and maybe there is someone on the Collector boards who would know a good answer!).

XanderBakker
Esri Esteemed Contributor

I guess ArcGIS Online is the proper space to ask the question since this is where the symbology is defined. You may want to check out this document posted by Jake Skinner : Show Attachments in Web Map Popup which shows a method to show the attachment in the popup.

I guess you could use some Arcade (see ArcGIS Arcade | ArcGIS for Developers ) to accomplish this, but if the data is dynamic (still being edited) this may become a challenge. 

Arcade allows you to create an expression to symbolize your data. If in your webmap you go into the symbology of the layer, you can scroll down on the field to use until you see "new expression" at the bottom. This will open the expression window, where you could enter the expression. For example something like this:

var parentIDs = ['6c7e58b4-637e-4031-a672-cc111201e466', '2e49394e-aa32-45d4-b2ab-6a83f7de5d3c', 'a8180679-33a3-4a15-b5a5-c18b6c2fda19', '6ad52c32-7436-49c1-93dd-538b625da159', '40571e30-81f8-4829-8cbf-8e9d3860ad5b'];
var result  = "no Photo";
If (IndexOf(parentIDs, $feature.GlobalID) != -1) {
    result = "Has Photo"
};
return result;‍‍‍‍‍‍‍‍‍‍‍

The parentIDs where extracted from the REST service using the QueryAttachements task and using some Python to extract the values into an array. If the data is dynamic (still being edited) it might be possible to use a REST query in the Arcade expression, but this might kill the performance...

After the expression is defined, you can edit the symbology:

And you will see that when clicking on a grey (no Photo) point it will return this:

Clicking in a point with the photo icon, will show the attachments:

If it is not possible now to include the REST request in the Arcade expression, it will be with the next release, since there will be mayor improvements on Arcade due to the implementation of the new Network Management System in the entire platform. 

PanGIS
by
Regular Contributor

Xander,

thank you, this looks very interesting.

it's true that our feature may be updated (both geometry and attribute).

Anyway, since is something new and i am curious to see how it works, I'll have a look at it tomorrow and I'll let you know.

0 Kudos
MikeBollinger
New Contributor

Hi Xander,

Indeed this looks like a promising solution. Could you explain how you could get the "ParentID" if you're working with a feature service in AGOL? Could you explain or provide a link to what a "REST query in the arcade expression" would look like?

Thanks!

0 Kudos