Can I use an expression in Field Maps that autocompletes a field based on the ObjectID?

821
3
Jump to solution
04-12-2022 06:51 AM
David_Brooks
MVP Regular Contributor

This is a quesiton in lieu of Attribute Rules. I have arborists collecting data about Trees. They give each tree a unique reference (T1, T2 and so on). I would like this field in their form to automatically complete based on the object ID as the default value. But I would also like them to be able to edit this value if they wish.

Is there a way of using an expression to set a default value thats "T"+!ObjectID! or something along these lines?

The alternative would be just to remove this field and just use the object ID, and generate a Tn reference after Field Mapping.


David
..Maps with no limits..
0 Kudos
1 Solution

Accepted Solutions
HuubZwart
Occasional Contributor

You could create an arcade expression to fetch the latest OBJECTID using Arcade, add 1 and go from there: 

var itemid = // your portal item id
var portalurl = // your portal url or "https://arcgis.com"
var fs = FeatureSetByPortalItem(Portal(portalurl),itemid)
return Max(fs, "OBJECTID") +1 

This might not be the best way to go though if you have multiple users collecting data simultaneously or have users that work offline. An attribute rule will probably be a better idea indeed. 

View solution in original post

0 Kudos
3 Replies
HuubZwart
Occasional Contributor

You could create an arcade expression to fetch the latest OBJECTID using Arcade, add 1 and go from there: 

var itemid = // your portal item id
var portalurl = // your portal url or "https://arcgis.com"
var fs = FeatureSetByPortalItem(Portal(portalurl),itemid)
return Max(fs, "OBJECTID") +1 

This might not be the best way to go though if you have multiple users collecting data simultaneously or have users that work offline. An attribute rule will probably be a better idea indeed. 

0 Kudos
David_Brooks
MVP Regular Contributor

@HuubZwart that's a nice idea, but they're exclusively offline, so Im guessing this wouldn't work. As it has been for the last 2 years; I will await Attribute Rules on AGOL!


David
..Maps with no limits..
0 Kudos
kmsmikrud
Occasional Contributor III

Hi,

I would also like to have a sequential ID offline, but it can be related to the Field Maps user and not the entire dataset.

Did you figure out a work around for this?

Thanks!,

Kathy

0 Kudos