Hello,
I am trying to use the expression mentioned on this page to generate the next number in a field that stores the record number of observations collected in the field. The field idlong is an integer field and is located in the hosted feature layer DataCollectionInspection.
Here is my version of the arcade expression:
Solved! Go to Solution.
Hi @dsinha ,
It loos like you just have a typo on the second line.
Right now your expression says '<idlong DESC', but it should just be 'idlong DESC'. The opening bracket looks like it was copied from the example but wasn't deleted.
Hope that helps!
Chris
Hi,
I noticed a typo in this line of code:
var topnum = Top(OrderBy(numberlist,'<idlong DESC'),1)
It should be:
var topnum = Top(OrderBy(numberlist,'idlong DESC'),1)
I hope this works.
Sure thing - I think you could do it two ways:
var numberlist = $layer
If you use that for the first line instead of the feature set expression, the rest of the code should work the same.
I believe you could remove the first line and instead go right to:
var topnum = Top(OrderBy($layer,'idlong DESC'),1)
I haven't tested that though.
Hi @dsinha ,
It loos like you just have a typo on the second line.
Right now your expression says '<idlong DESC', but it should just be 'idlong DESC'. The opening bracket looks like it was copied from the example but wasn't deleted.
Hope that helps!
Chris
Hi,
I noticed a typo in this line of code:
var topnum = Top(OrderBy(numberlist,'<idlong DESC'),1)
It should be:
var topnum = Top(OrderBy(numberlist,'idlong DESC'),1)
I hope this works.
Thank you so much! Completely missed that bracket 😊
I have a follow-up question: Does this Arcade expression (and Arcade expressions in general) work in the offline mode?
Hi @dsinha - in general most Arcade expressions will work offline, but there are a few exceptions. Anything that sends a request to the server will not work, so something like featureSetByPortalItem would not work. In this case, I believe calling the feature set by name within the map will work, however it will only query features that are within the offline area. If you are not taking the entire feature set offline with your offline area then the results from this query may not be accurate.
It is also worth noting that if you have multiple people working with offline areas they would end up creating duplicate unique identifiers which would likely cause some data problems down the line, depending on your workflow.
Thanks for your reply @ChrisDunn1. I did take the entire feature set offline, but it is not autogenerating the number.
I may have been mistaken - it might be that all FeatureSet functions do not work offline, however $layer might work to access the IDs instead of FeatureSetByName, that would be worth trying.
Sorry @ChrisDunn1, I am not well-versed in Arcade. Could you suggest how the expression would read with $layer instead of FeatureSetByName? I am assuming its just the first line. Thanks for your help!
Sure thing - I think you could do it two ways:
var numberlist = $layer
If you use that for the first line instead of the feature set expression, the rest of the code should work the same.
I believe you could remove the first line and instead go right to:
var topnum = Top(OrderBy($layer,'idlong DESC'),1)
I haven't tested that though.