Show Attachments in Web Map Popup

128964
416
12-14-2015 08:10 AM

Show Attachments in Web Map Popup

I work with a lot of customers that request the ability to display their feature service attachments in the web map's popup rather than a hyperlink.  The attached script will convert the feature services attachments URL to a field.  You can then display the attachment directly in the popup after some configuration.

 

Here is a screen shot on how attachments display within a web map popup by default:

 

Screen1.PNG

 

Below are the steps to show the attached image directly in the popup:

 

1.  Add a TEXT/STRING field (i.e. "Picture")  to the feature service that can support a large amount of characters (i.e. 1,000).

2.  Execute the attached GP tool.

3.  Configure the pop-up to Show Images.  Ex:

 

Screen2.PNG

 

The image will now display directly in the popup.  Ex:

 

Screen3.PNG

 

Notes:

  • the timeout for an ArcGIS Online feature service is set to the max of 15 days.
  • the timeout for an ArcGIS Server service is set to the default 'Lifespan of long lived token'.  The default is 1 day.  This can be changed by going to Server Manager > Security > Settings.  After the long lived token is updated, you can update the expiration parameter on line 33.
  • Since the token will timeout, you can update the parameters in the script so this can be executed with Windows Task Scheduler.  Here is an example of how to configure the parameters:

 

A video of the workflow can be found below:

https://www.youtube.com/watch?v=WpLJBZ9gnuw

Attachments
Comments
OrcaMaritime
Emerging Contributor

Jake,

I'm having an error when running the script in Pro. It is saying that my web layer doesn't have attachments, but as you can see on the right-hand side of the image, that it does have attachments.

Screenshot

JakeSkinner
Esri Esteemed Contributor

Orca Maritime‌ can you share the service to an AGOL Group and invite my user account (jskinner_CountySandbox)?

JoeBryant1
Frequent Contributor

Has anyone figured out how to run this script without updating the editor tracking? I'd like to retain the editor username and last edit time stamp of my field collectors. I'm currently using hosted feature services in ArcGIS Online.

JoeBryant1
Frequent Contributor

I figured out I could manually turn of editor tracking on the layer, save, run the script, turn it back on and save again. A little tedious, but it works. Now I just have to remember!

It would be nice to be able to include a "disable" and "re-enable" editor tracking function at the beginning and end of this GP tool. Maybe even allow you to toggle editor tracking off in the user dialog.

DambéSANWOGOU
Regular Contributor

Hi Jake Skinner‌, i have the same problem, after a few days, my image don't display, i use arcgis Online

JakeSkinner
Esri Esteemed Contributor

Dambé SANWOGOU‌ the pop-ups should be retained for 15 days before you have to execute the tool again.  Have you tried configuring the variables in the script and having Windows Task Scheduler run the script (see the example in the document)?  You could schedule the script to run nightly and you won't have to worry about the token expiring, which causes the images to no longer display.

CarlosColegios
Emerging Contributor

Hello:

When I take data with Collector for ArcGIS, (image included), I can not get the image to appear in the pop-up.

Only the link to it appears. What do I have to do to be able to insert it as an image?

In this window, the field of the images (attachments) does not appear.

Thank you

JakeSkinner
Esri Esteemed Contributor

Carlos Colegios‌ follow the steps in this document.  You first will add a new TEXT field to your service, and then execute the attached tool to up this field with the URL to the attachments.

CarlosColegios
Emerging Contributor

Hello:

I created the image field (text), but I do not know how to run the

Attachments to Popup tool. I do it from ArcGIS Online. I unzip the tool and

that's where I arrived. What do I do with the unzipped file?

Can you tell me, please, how it is done?

Thank you

Carlos

El lun., 17 jun. 2019 a las 14:19, Jake Skinner (<geonet@esri.com>)

escribió:

GeoNet, The Esri Community | GIS and Geospatial Professional Community

<https://community.esri.com/?et=watches.email.document_comment>

Show Attachments in Web Map Popup

new comment by Jake Skinner

<https://community.esri.com/people/jskinner-esristaff?et=watches.email.document_comment> View

all comments on this document

<https://community.esri.com/docs/DOC-7445-show-attachments-in-web-map-popup?commentID=74552&et=watches.email.document_comment#comment-74552>

JakeSkinner
Esri Esteemed Contributor

Carlos Colegios‌ you will need to run the tool from ArcMap or ArcGIS Pro.

SamanthaGriffore
Regular Contributor

Hi Jake Skinner‌, I'm getting a similar error. I've checked that my feature service is enabled for editing and have added the index to the end of the URL. Any ideas why I'm getting this error?

JakeSkinner
Esri Esteemed Contributor

Samantha Griffore‌ what type of authentication are you using for ArcGIS Online?  For example, are you using built-in users, Active Directory, ADFS?  This tool currently only supports built-in and Active Directory.

Also, could you share the service to a Group and then invite my user account (jskinner_CountySandbox)?

SamanthaGriffore
Regular Contributor

Jake Skinner‌ Invite has been sent. I believe we use local users, but I'm checking on that.

JakeSkinner
Esri Esteemed Contributor

Samantha Griffore‌ your feature service URL is incorrect.  It should end with /2.  Here is how I had the tool setup:

SamanthaGriffore
Regular Contributor

Thanks Jake Skinner‌. Might be a silly question, but how do I know which index number to put in? Is it based on where it is in my list of items in my specific folder/group/content? "2" didn't work for me, trying other numbers now.

JakeSkinner
Esri Esteemed Contributor

Samantha Griffore‌ if you go to the Details of the service, scroll all the way to the bottom, and click View:

This will open REST services directory page.  You can then see the index number of the layer (i.e. 2):

If you click on the layer name, you will see it appends /2 after /FeatureServer in the URL.

SamanthaGriffore
Regular Contributor

Thanks Jake Skinner‌. Unfortunately, still getting the same error. At this point it's not crucial, but a nice to have. I'll let you know if I figure it out.

URL:

https://services6.arcgis.com/ubm4tcTYICKBpist/ArcGIS/rest/services/NR_Projects_Specific_Location/Fea...

Error: Line 34 -- "token = response.json()['token']": 'token'

Completed script Attachments to Popup...

Failed to execute (AttachmentstoPopup).

DambéSANWOGOU
Regular Contributor

Hello Jake Skinner, I have this error after several attempts. Here is my error message.

Exécution du script AttachmentstoPopup...
ObjectID: 14 successfully updated.
Error:  Line 103 -- "": ('Connection aborted.', error(10054, 'Une connexion existante a d\xfb \xeatre ferm\xe9e par l\x92h\xf4te distant'))
Completed script AttachmentstoPopup...
Échec de l’exécution de (AttachmentstoPopup).
Échec à Wed Aug 28 16:05:48 2019 (temps écoulé : 19,92 secondes)

I also wanted to know if there is another way to display the images after 15 days.

Best regards,

Anselme

JakeSkinner
Esri Esteemed Contributor

Dambé SANWOGOU‌ can you send a screen shot of how you have the tool setup? 

If the service is hosted in ArcGIS Online, 15 days is the max, however you can script this and use Windows Task Scheduler to execute the script.  See the Notes section above.

DambéSANWOGOU
Regular Contributor

Thanks Jake Skinner

Ok for this error :

Exécution du script AttachmentstoPopup...
ObjectID: 14 successfully updated.
Error:  Line 103 -- "": ('Connection aborted.', error(10054, 'Une connexion existante a d\xfb \xeatre ferm\xe9e par l\x92h\xf4te distant'))
Completed script AttachmentstoPopup...
Échec de l’exécution de (AttachmentstoPopup).
Échec à Wed Aug 28 16:05:48 2019 (temps écoulé : 19,92 secondes)

Best regards,

Anselme

JakeSkinner
Esri Esteemed Contributor

Dambé SANWOGOU‌ can you send a screen shot of the tool before you click OK/Run to execute it.  Example:

DambéSANWOGOU
Regular Contributor

Jake Skinner‌ thait is the screenshot, i use arcmap 10.7.7

JakeSkinner
Esri Esteemed Contributor

Dambé SANWOGOU‌ can you share the service to an ArcGIS Online Group and invite with my user account (jskinner_CountySandbox) to this Group?  I can run a test with the service.

DambéSANWOGOU
Regular Contributor

Jake Skinner‌ Invitation sent.

Regards,

JakeSkinner
Esri Esteemed Contributor

Dambé SANWOGOU‌ the feature service does not have editing enabled.  You need to enable this since this tool updates a field.

JoeBryant1
Frequent Contributor

Hi Jake, thanks for clarifying that you need to enable editing above. I had to create a new View, make it editable and use that service URL in the script (the layer I am updated is public so I shouldn't enable editing on it).

I'm attempting to schedule this with Windows Task Scheduler and have altered the script as in your Notes. However, there is no attribute "disable_warnings' in the requests module. Any ideas?

Here is the error:

>>> import requests
>>> requests.packages.urllib3.disable_warnings()
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'disable_warnings'

JakeSkinner
Esri Esteemed Contributor

Not sure why you are receiving that error.  What version of Python are you running?  However, that line will not be needed.  You can comment it out.  You may just receive some certificate warnings in the python interpreter when you execute the script.

JoeBryant1
Frequent Contributor

Thanks Jake. I did end up commenting it out with no issues.

I’m on Python 2.7 and ArcMap 10.4.1. I also tried it in Pro 2.3 with whatever version of Python that uses (I’m still confused on how to switch between the two).

Searching around, it looks like the Requests module didn’t get installed with Arc Desktop until 10.5. As I do have a requests module installed, it just doesn’t have the “disable_warnings” attribute, maybe Pro 2.3 comes with a version of the module that doesn’t include this attribute?

FYI: I found the most recent “Requests” module installer on the web: https://2.python-requests.org/en/master/ ; I just haven’t gotten IT to install it yet to test. I don’t see “disable_warnings” in the TOC for the module, though. Stack Overflow says urllib3 is not part of the requests module anymore, as of the 2017 revision (>=2.16.0): https://stackoverflow.com/questions/27981545/suppress-insecurerequestwarning-unverified-https-request-is-being-made-in-pytho

Joe Bryant

GIS Coordinator

WEST YOST ASSOCIATES

direct 530.761.0226

NicholasHumphrey
Emerging Contributor

Is there a way to center to image in the popup?

ShelbyZelonisRoberson
Frequent Contributor

Hi Jake, apologies if this has been asked before but I'm having trouble with using the script with ArcGIS Server. I believe the problem is my Portal Server URL, but not sure what to adjust to fix it. Is it because I'm using a web adaptor URL? Here is a screenshot of my inputs and error message: 

Thanks!

JakeSkinner
Esri Esteemed Contributor

Shelby Roberson‌ yes, you will need to go around the web adaptor by specifying the Fully Qualified Domain Name and port 7443.  Ex:

https://portal.esri.com:7443/arcgis

PeterGoedbloed
Emerging Contributor

Hi Jake,

I can't get this tool working for Portal for ArcGIS 10.7.1 as I am stumbling upon some token errors:

JakeSkinner
Esri Esteemed Contributor

Peter Goedbloed‌ if you copy the URL referenced in the error (i.e. https://portal.domain.com:7443/arcgis/sharing/rest/generateToken) and place it in a web browser from your client machine, does it resolve successfully?  Ex:

TimSolomonson
Emerging Contributor

@JakeSkinner ‌, i'm having the identical issue @SamanthaGriffore is having and haven't been able to resolve the issue. 

I've added you to a group with the same title as this post.  the servicelayer in question should be shared to you in there.

Error message:

TimSolomonson_0-1607108122052.png

 

 

JakeSkinner
Esri Esteemed Contributor

@TimSolomonsonyou need to enable editing on the Feature Service.  You can do this by going to the Settings.

MatthewWithum
Occasional Explorer

Working like a charm in ArcPro 2.7. What are your thoughts on displaying a pdf in pop up rather than JPEG? Any foreseeable, additional configuration required? Thank you for this sweet script, moreover maintaining this forum over the years. Great work. @JakeSkinner 

JakeSkinner
Esri Esteemed Contributor

@MatthewWithumI haven't tested a PDF, but it should work the same as a JPG.

by Anonymous User
Not applicable

Hi Jake,

 

what If we overwrite the feature layer? should we setup this again in the web map?

JakeSkinner
Esri Esteemed Contributor

@Anonymous Useryes, if you overwrite the layer the field that contains the URL will most likely be blank, so you will have to re-execute the tool to populate it.

GISREAL
Emerging Contributor

Hello. Can you suggest a page where I can learn to do this? I am really a newbie when it comes to script. Thanks in advance!

JakeSkinner
Esri Esteemed Contributor


@GISREAL below is a video that walks through the workflow:

https://www.youtube.com/watch?v=WpLJBZ9gnuw

DickieRigdon
Regular Contributor

Hi @JakeSkinner ,

Hope you're still following this thread. I'm getting the same error for line 34 as @TimSolomonson and @SamanthaGriffore.  I do have "Editing" enabled on my layer.  I used /0 in my url as that is what my layer has. Thanks for any tips. -Dickie

DickieRigdon_0-1658360583766.png

 

JakeSkinner
Esri Esteemed Contributor

@DickieRigdon if the service is an AGOL hosted feature service, can you share the service to a group and invite my user account (jskinner_CountySandbox)?  I can take a look to see what's going on.

DickieRigdon
Regular Contributor

@JakeSkinner invitation sent.  Thanks

JakeSkinner
Esri Esteemed Contributor

@DickieRigdon,

The tool is working from me on my end.  Can you send a screen shot of how you have the GP tool configured?

JakeSkinner_0-1658755431808.png

 

DickieRigdon
Regular Contributor

toolbox_run_error.JPG

@JakeSkinner 

Tried it again, same error.

JakeSkinner
Esri Esteemed Contributor

@DickieRigdon check your username.  It is case sensitive.  For example, if I try jskinner_countysandbox, I receive the same error.  However, jskinner_CountySandbox works.

DickieRigdon
Regular Contributor

@JakeSkinner  Success!  That was it.  I was using all lower case in toolbox username.  Funny, I can login though to AGOL using all lower case.

I'll work to complete the rest of your workflow now.

Thank you Jake!

DickieRigdon
Regular Contributor

@JakeSkinner   Hi Jake, the workflow is working great with the manual token refresh and I'm going to see if the organization can run the Task Scheduler as well.  One question, if new records are added to the ArcGIS Pro dataset, will my same toolbox work with the updated data?  The dataset will constantly grow in entries every month.  I'm building a web map app that will publish the data.

 

JakeSkinner
Esri Esteemed Contributor

@DickieRigdon yes, as the dataset grows, the field you created to store the URL will update each time the script is executed.

Version history
Last update:
‎02-28-2022 04:19 AM
Updated by:
Contributors