Trying to populate fields by intersect, from another layer in the fieldmap

59
2
Jump to solution
a week ago
DavidCarroll94
New Contributor

Hello all, 

I'm trying to use Field Maps to create a form for field data collection.

We've got areas that need to be surveyed which I've got as a pre-existing polygon layer.

I've set up the field map to have the survey Location name (which is prepopulated) and then survey date and surveyor's name to be collected when they arrive. 

I've been trying to use an arcade expression to pass the surveyor name and survey date to another (point) layer using intersects / within, but am having no luck. 

Using this code I've at least seen the field-headings in the "test" section:
var Mines_Info = FeatureSetByName($map, "Mine_Locations")
var MInfo = Intersects($feature, Mines_Info)
return MInfo

But I'm at a loss as to how to pass the information I want through. I either get a "Cannot access property of a null object" error in the arcade window, or a "Failed to calculate" error on the Field Maps app. 

Thankyou!

0 Kudos
1 Solution

Accepted Solutions
SarahSaint-Ruth
Esri Contributor

Hi David,

The issue is likely because you are returning a feature set rather than a specific feature even though there is an intersect. You also need to tell the Arcade editor what field value you want to return.

var Mines_Info = FeatureSetByName($map, "Mine_Locations", [‘the field name you want to return’])

MInfo= first(intersects($feature, Mines_Info)

Return Minfo[‘the field name you want to return’]

Another option is you could use the following Arcade functions to return the user name and date.

Date: Now() this will returns the current date and time in the local time of the client.

User Name: GetUser($layer).fullName

 

We have a blog here with the most common expressions used in Field Maps in case this helps for future expressions.

 

View solution in original post

2 Replies
SarahSaint-Ruth
Esri Contributor

Hi David,

The issue is likely because you are returning a feature set rather than a specific feature even though there is an intersect. You also need to tell the Arcade editor what field value you want to return.

var Mines_Info = FeatureSetByName($map, "Mine_Locations", [‘the field name you want to return’])

MInfo= first(intersects($feature, Mines_Info)

Return Minfo[‘the field name you want to return’]

Another option is you could use the following Arcade functions to return the user name and date.

Date: Now() this will returns the current date and time in the local time of the client.

User Name: GetUser($layer).fullName

 

We have a blog here with the most common expressions used in Field Maps in case this helps for future expressions.

 

JustinReynolds
Occasional Contributor III

"I've been trying to use an arcade expression to pass the surveyor name and survey date to another (point) layer using intersects / within, but am having no luck. "

I'm a bit murky on what you are trying two accomplish.  It sounds like you are trying to change another features attributes, rather than the feature in your current edit session.  If so, be aware that you can only change the values of the current feature.  You can retrieve data from another layer, but only for the purpose of manipulating you current form or feature.


Also be aware that the Intersects function has to forms.  It can return Boolean (true/false) if comparing two geometries or a featureSet if comparing a featureSet to some inputGeometry. 

You may also want to test that Mines_Info is not empty before trying to do the intersect as that may explain your failed to calculate or null object error as well.

As Sarah mentions above, you can't return a featureSet.  The Form Calculation Arcade Profile only supports the return types of Number, Date, or Text. https://developers.arcgis.com/arcade/profiles/form-calculation/

 

- Justin Reynolds, PE
0 Kudos