Hi everyone,
I've been searching for possible help on this one, but can't find exactly what I need to figure out the arcade script for the following.
All fields mentioned are in the same hosted layer.
Based on the values in SHARING field (Public, Semi-Private, and Private) I need to restrict some or none of the other fields from the same layer from showing.
Examples
- PUBLIC: all fields can show, no restrictions
- SEMI-PRIVATE: only Field1, Field2, Field3, Field4 can display in the pop-up
- Private: only Field1, and Field2 can display in the pop-up
Any help would be amazing!
Thank you
You can do this with an Arcade Popup Element, building the field list based on the sharing attribute.
// field objects to hold our popup contents; since even private has fields 1 and 2, we'll start with those
var fieldInfos = [
{fieldName: 'field1'},
{fieldName: 'field2'}
]
var attributes = {
field1: $feature['field1'],
field2: $feature['field2']
}
// get sharing attribute
var sharing = $feature['SHARING']
// if semi-private, add next set
if (sharing == 'SEMI-PRIVATE' || sharing == 'PUBLIC') {
Push(fieldInfos, {fieldName: 'field3'})
attributes['field3'] = $feature['field3']
Push(fieldInfos, {fieldName: 'field4'})
attributes['field4'] = $feature['field4']
}
// if public, add the rest
if (sharing == 'PUBLIC') {
Push(fieldInfos, {fieldName: 'field5'})
attributes['field5'] = $feature['field5']
// and so on, for the rest of the attributes
}
return {
type: 'fields',
fieldInfos: fieldInfos,
attributes : attributes
}
Hi Josh,
Thank you so much for the detailed reply.
I was able to updated your code to include all of the fields I need. However, the pop-up content doesn't seem to actually change based on the "sharing" value. All records, regardless of their "sharing" value are displaying all 11 fields.
Below is the code I modified. Any thoughts?
Hi Josh,
I'm curious if you had a moment to look at my previous reply.
Thank you,
Vanessa
Hi Vanessa, Just wondering if you got the expression to work? I am trying to do something similar.
Thanks!
Erin
Hi Erin,
No unfortunately I didn't. I tried the code provided by Josh, but something still wasn't working right. If you find a solution, please feel free to share!
Vanessa