Select to view content in your preferred language

URL link to Attachment Photo when the FeatureLayer is not Shared with Everyone

3060
3
04-25-2019 10:29 AM
JohnEvans6
Regular Contributor

Hi All,

This is the workflow I am looking to accomplish:

  1. Responder fills out a Survey123 Form. Responder takes a picture of the current situation and uploads on submission
  2. A calculated field would copy the URL of the attachment (Basically like this)
  3. The Survey123 FeatureLayer is ingested into our custom COP (Common Operating Picture) for situational awareness/analysis. We're not consuming Survey123's data on Arcgis Online/Portal map
  4. User can click the pop-up window in our COP and open the hyperlink

Issue: FeatureLayer Permissions. We don't care about everyone having view access to the layer. We do care about everyone having edit rights. If we restrict the Feature Layer Permissions in Portal to a specific Group, the URL hyperlink, generates with ?token=zzz. We want the FeatureLayer image urls to not require a token, which the only way I can see to fix that is sharing it with everyone, which implicitly gives everyone edit rights.

Is there a way to configure a FeatureLayer to be globally viewable, but editable only to those who are members of a group in portal?

Or

Is there a way to configure Survey123 to upload/host images somewhere else?

Thanks!

0 Kudos
3 Replies
JamesTedrick
Esri Esteemed Contributor

Hi John,

It sounds like you might want to take advantage of feature service views to provide access, assuming you are using Enterprise 10.6 or later (Create hosted feature layer views—Portal for ArcGIS | ArcGIS Enterprise ).  One way to do this is to share the survey for viewing in the Survey123 website - that will create a feature service view that is read only, but points to the same tables as the editing.  You could then share that to everyone and base the link off the service URL of that view; this would allow you to keep the editing feature service limited to the editor group.

JohnEvans6
Regular Contributor

Hi James,

I had messed with views, but didn't realize you could create the view directly from Survey123. That was a super helpful, Thanks! I think I'm incredibly close to getting it set up to do what we need. I'll spell out what I'm doing in the off-chance it helps someone else out

1. Survey123 Data is updated by a Field Operator and an image is attached. It's added to the Surveys Submitter Feature Layer

2. Under Survey123 -> Collaborate -> Viewer, set viewer to everyone and Save. This builds a new stakeholder Feature Layer hosted view

3. The fieldworker view (Collaborate -> Submitter in Survey123), which is editable to my organization only, will have an additional field and field calculator script that generates a URL that references the attachments in the stakeholder (read only shared with everyone) view . Script would do something like this:

oid = !ObjectID!

def MakeURL(oid) :
 userImg= 'https://services1.arcgis.com/xxx/ArcGIS/rest/services/survey123_xx_stakeholder/FeatureServer/0/'+str(oid)+'/attachments/'+str(oid)
 return userIMG

The end result should be a link to an attachment that was previously restricted, requiring token, and consumers can make no edits.

Thanks for the direction!

0 Kudos
JohnEvans6
Regular Contributor

Resolved this. Ended up being very straightforward. Update script at the end is not production ready, but worked for the proof of concept I had to demo:

  1. Created a Survey in Survey123. I set Submitter settings to a specific organization group. I used the desktop app to create a read only field to hold the url link within the survey
  2. In my organization (not through survey, though I'm sure it would work the same), I created view only layer and shared it with everyone.
  3. Get the service URL of the shared with everyone view
  4. A script runs to update the img_url field of the survey hosted feature layer (not view)

import arcpy
from arcgis import GIS
import pandas as pd
import time
from copy import deepcopy

# Connect to FAASYSOPS Portal
oursite = GIS("url","user", password)

#Update the image field
def UpdateImageField() :

    # init some stuff
    features_to_be_updated = []
    field_service_dataframe = ''

    try :
       
        # Get Field Service Layer (not the view layer)
        field_service = oursite .content.get('survey123hostedfeaturelayerid')
        field_service_layer = (field_service.layers)[0]

        # Build Data Frame
        field_service_dataframe = pd.DataFrame.spatial.from_layer(field_service_layer)

        # Iterate through dataframe.
        for row in field_service_dataframe.iterrows() :
            if (row[1]['imageurl'] == None or row[1]['imageurl'] == '') :
                # Get ObjectID and set image URL
                objID = str(row[1]['objectid'])
                img_url = "urloftheview_View/FeatureServer/0/{0}/attachment/{0}".format(objID)

                # init feature and get feature from service
                feature_to_update = ''
                feature = field_service_layer.query(where='OBJECTID = ' + objID)

                # Make a deep copy so we keep our attributes/structure and update data
                feature_to_update = deepcopy(feature.features[0])

                # Make Field Update
                feature_to_update.attributes['imageurl'] = img_url
                features_to_be_updated.append(feature_to_update)

        if len(features_to_be_updated) != 0 :
            field_service_layer.edit_features(updates = features_to_be_updated)
    except :
        print ('Error making update. Do some real error catching or something.')

while True :
    UpdateImageField()
    time.sleep(15)
0 Kudos