Following Arcade function in online map works well when open map with map viewer.
But it will cause error "Error Domain=com.esri.arcgis.runtime.services.error Code=500 "The submitted field '*' is not available in the layer '0' of the service" in Field Maps log when use latest Field Maps to open the map and show the link in the map popup.
But if create offline area with Field Maps then the links shows well in the offline map.
Decode the URL in the Field Maps log and notice that the Arcade Filter function "var patrolsToday=Filter(resultFeatureSet,"patrol_date_time>=@todayValue AND patrol_subsector=@patrolSubsector AND record_as_patrol='yes'");" was changed to:
'query?f=json&outStatistics=[{"statisticType":"count","onStatisticField":"*","outStatisticFieldName":"result"}]&where=(patrol_date_time>=DATE'2021-03-10' AND patrol_subsector='NS-20-090-001 (Cumberland Basin-Maccan River)' AND record_as_patrol='yes')"
So it means this part "outStatistics=[{"statisticType":"count","onStatisticField":"*","outStatisticFieldName":"result"}]" was added by Field Maps and caused that error?
Here is the Arcade function:
var resultFeatureSet=FeatureSetByName($map,"Survey Result");
var patrolSubsector=$feature["PATROL_SUBSECTOR"];
//var todayValue=Date(Year(Today()),Month(Today()),Day(Today()),Hour(Today())+12);
var todayValue=Today();
var patrolsToday=Filter(resultFeatureSet,"patrol_date_time>=@todayValue AND patrol_subsector=@patrolSubsector AND record_as_patrol='yes'");
var patrolsTodayCount= IIf(IsEmpty(patrolsToday), 0, Count(patrolsToday));
var patrolsRequired=$feature["PATROLS_REQUIRED"];
var surveyURL="surveyurl"+"&field:patrol_sector_objectid="+$feature.OBJECTID+"&field:detachment="+Replace($feature.DETACHMENT ," ","%20")+"&field:po_number="+Replace($feature.PO_NUM,",","%2C")+"&field:dfo_region_code="+$feature.DFO_REGION_CODE+"&field:patrol_subsector="+Replace($feature.PATROL_SUBSECTOR," ","%20")+"&field:risk_category="+$feature.RISK_LEVEL+"&field:completed_patrols_in="+$feature.PATROLS_COMPLETED+"&field:remaining_patrols_in="+$feature.PATROLS_REMAINING+"¢er="+$feature.LATITUDE+","+$feature.LONGITUDE;
surveyUrl=IIf(patrolsTodayCount>=2,"This subsector has been patrolled 2 times today",IIf(patrolsRequired==0, "Not Required", surveyURL));
return surveyUrl;
Here is the error in Field Maps log:
2021-03-10, 3:12 PM expr0 (Survey Link) error: Error Domain=com.esri.arcgis.runtime.services.error Code=500 "The submitted field '*' is not available in the layer '0' of the service 'service_25b3c7f799d64463848367cbd79a69f7'." UserInfo={NSURL=.../FeatureServer/0/query?f=json&outStatistics=%5B%7B%22statisticType%22%3A%22count%22%2C%22onStatisticField%22%3A%22%2A%22%2C%22outStatisticFieldName%22%3A%22result%22%7D%5D&where=%28patrol_date_time%3E%3DDATE%20'2021-03-10'%20AND%20patrol_subsector%3D'NS-20-090-001%20%28Cumberland%20Basin-Maccan%20River%29'%20AND%20record_as_patrol%3D'yes'%29, NSLocalizedDescription=The submitted field '*' is not available in the layer '0' of the service 'service_25b3c7f799d64463848367cbd79a69f7'., responseJSON={
error = {
code = 500;
details = (
);
message = "The submitted field '*' is not available in the layer '0' of the service 'service_25b3c7f799d64463848367cbd79a69f7'.";
};
}}