Arcade Filter function doesn't work with Field Maps for online map

376
5
Jump to solution
03-10-2021 12:43 PM
Ming
by
New Contributor III

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+"&center="+$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'.";

    };

}}

 

 

1 Solution

Accepted Solutions
Dominique_Broux
New Contributor II

@Ming wrote:
but just curious with same Arcade expression for popup why the Field Maps doesn't support when it is online map, but support with downloaded offline map.

They have same content and the only difference is the online map disabled the offline option.


The count statistic query is not done the same way for online tables and for local tables.

Not sure of the root cause yet but it seems the online implementation is not working with your service.

Thank you for raising this issue, we'll let you know once a fix is available.


View solution in original post

0 Kudos
5 Replies
ChrisDunn1
Esri Contributor

Hi Ming,

For the initial FeatureSet call - 

var resultFeatureSet=FeatureSetByName($map,"Survey Result");

Is "Survey Result" a feature layer or a table?

If it is a table that will explain the issue - there is a known bug where FeatureSetByName will not work with Tables, that has been resolved and the fix will come out with our upcoming release of Field Maps.

If Survey Results is not a table, are you able to share the map so we can look more closely at how everything is configured?

Chris

0 Kudos
Dominique_Broux
New Contributor II

Hi Ming,

After a first quick investigation, it seems this service doesn't answer as expected to a statistic query. It looks like it doesn't accept the generic field "*" as 'onStatisticField'

Example of failing query
while the same kind of query seems to work with other services: example

We need more investigations to understand and fix this issue.

Meanwhile, the only workaround I can figure out is to replace 'Count(patrolsToday)' by a loop on the features, something like:

var patrolsTodayCount=0
for(var patrolToday in patrolsToday)
  patrolsTodayCount++

Note: to limit the performance impact we can also break the loop when patrolsToday>=2 since it seems you only need to know if it's >= 2 or not.


0 Kudos
Ming
by
New Contributor III

Thank you @Dominique_Broux and @ChrisDunn1 for your response.

The "Survey Result" is a hosted feature layer of Survey123 which is created automatically when publish survey with Survey123 Connect latest version, and here is the URL:

https://msdidfo7.esriservices.ca/arcgis/rest/services/Hosted/service_1095b7f5710c4d9195c73fa757690fe...

So don't know why it doesn't  accept the generic field "*" as 'onStatisticField'. 

Yes we can change the Filter logic, but just curious with same Arcade expression for popup why the Field Maps doesn't support when it is online map, but support with downloaded offline map.

Here is the  online map URL:

https://msdidfo7.esriservices.ca/portal/home/webmap/viewer.html?webmap=3e1ecc12f0ff4f2fb4e168817c712...

Here is the offline map URL:

https://msdidfo7.esriservices.ca/portal/home/webmap/viewer.html?webmap=d1eaa9e4024f46d0bdeef4eed8e6e...

They have same content and the only difference is the online map disabled the offline option.

Thanks again and please let me know if you need more information.

Ming
by
New Contributor III
0 Kudos
Dominique_Broux
New Contributor II

@Ming wrote:
but just curious with same Arcade expression for popup why the Field Maps doesn't support when it is online map, but support with downloaded offline map.

They have same content and the only difference is the online map disabled the offline option.


The count statistic query is not done the same way for online tables and for local tables.

Not sure of the root cause yet but it seems the online implementation is not working with your service.

Thank you for raising this issue, we'll let you know once a fix is available.


View solution in original post

0 Kudos