Arcade Expressions for conditional attributes in pop-ups within Collector

547
5
05-08-2019 01:47 PM
AmeWunderle
New Contributor II

I have a map in collector (19.0.1)  that I have linked with Survey 123. Once the survey is completed, the field crew update an attribute to change the symbol of the point so that they do not resurvey the same point. However, mistakes do happen (they click on a plot that they have already updated to 'Y') and as I want to make this as foolproof as I can, I would like to use an arcade expression so that the survey link only appears if the attribute in the feature service is 'N'. I used the following expression and it works within the browser of AGOL but not in the new collector application. What step am I missing? I have substituted our survey code for the word CODE as per our organization's requirements.

var Complete = $feature.Completed

var Surveylink = "arcgis-survey123://?itemID=CODE&field:Plot_Num={Plot_Num}&field:Block_Name={Block_Name}&field:FMU={FMU}&field:Year_Harv={Year_Harv}&field:Area={Area}&center={POINT_Y},{POINT_X}"

var noSurvey = ""

iif(Complete=='Y',noSurvey,Surveylink)

In the popup then I have the following: ><a href="{expression/expr0}" target="_blank">Survey Link</a>:

We generally only use Collector and Survey123 offline. Could that be the issue?

0 Kudos
5 Replies
MarkBockenhauer
Esri Regular Contributor

You could do something like this for your expression.

If an attribute is empty I show a survey link, Else I don't show the survey link.

var status = "text"

var openSurvey = ""
if(IsEmpty($feature.notes)){
status = "new"
openSurvey = '<a href="arcgis-survey123://?itemID=4560a3c533eb41fcb79fa3ec473babc8">Open Survey</a>'
}
else {
status = "done"
}
return status + " "+ openSurvey



I also used a similar expression to label the features according to status.

Mark

AmeWunderle
New Contributor II

Thanks Mark, that looks like a better way to run this. Does this work for offline data collection too?

0 Kudos
MarkBockenhauer
Esri Regular Contributor

Yes, this will work offline, provided the Field workers have the Survey on device and are synched with the latest data.  As Xander Bakker‌ said offline the data is not live, so if multiple people are working offline in the same area it is possible that they could submit for the same feature.

Mark

XanderBakker
Esri Esteemed Contributor

Nice use case, but there might be a problem. If you work offline, the link to start a survey will be active until the survey is synchronised. 

Another aspect is the way you construct the link. Arcade does not know what you mean with for instance "{Plot_Num}". You will have to specify the actual value of the field to make that work.

Question: what is CODE? Should that be provided as is, or is this too a field value?

AmeWunderle
New Contributor II

Thanks Xander. That's what I thought. We work far in the field, so we need to be offline. I had just hoped that by submitting the edit to the main feature (I have a feature class that I'm using for pre-set plots, whose attributes I send to partially populate the survey) of the Completed field from 'N' to 'Y' by the field crew (its a list) would then be enough to trigger the expression.

I didn't think of how arcade would handle the fields, oops. I had the link set up that way in the Pop-up for all plots previously, so those value would have been sent to Survey123 properly, but if I use arcade (which I'm new to) I will have to set it as $feature.Plot_num etc

CODE is a sub word for the application id of the survey itself. da4fetc123 etc...

0 Kudos