Hello,
Im trying to populate a field with sequentials numbers. This sequence it's grouped by an unique number (AKA Project Number). For any group of unique project number, it will create a sequential number 1 to X.
Hi @CristianGraf. You mentioned that the expression doesn’t work in Field Maps, are you seeing an error or is it returning an incorrect number? What kind of results are you seeing? And when you say that it works in a webmap, are you using a form or are you seeing the correct number in a pop-up?
A couple things:
1. The 'else' here doesn't do anything:
2. I think your filter functions may be broken, and therefore not returning any records to 'num_projet' and 'num_projet_corr'. The Filter functions uses a SQL92 expression, with use of the '@' symbol to use variables in the arcade.
The filter expression for 'num_project' is currently:
"numero_projet = '" + np_1 + "'"
But the SQL92 expression for this filter is:
`numero_project = @NP_1`
Likewise for numero_projet_corr:
`numero_projet_corr = @NP_1`
--- Optimizing this calc --- Extra
If you want to improve the efficiency of this calculation, consider nesting the featureSet based calls, which result in more traffic. For your code, you're making 3 calls to the feature:
- FeatureSetByName
- Filter
- Filter
** i don't remember if Count hits the featureSet, but if it does, you'd be making 5.
If you'd like to simplify your code, you could replace this section:
----
var numberlist = FeatureSetByName($map,"Poteau (Lien Survey123)")
var num_proj = Filter(numberlist, "numero_projet = '" + np_1 + "'")
var num_proj_corr = Filter(numberlist, "numero_projet_correction = '" + np_1 + "'")
var counter = Count(num_proj)
var counter_corr = Count(num_proj_corr)
var id = counter+counter_corr+1
---
** Code Block with all corrections: **