Pull attributes from one layer to another in Field Maps

3606
10
03-08-2022 06:36 AM
JessicaWay1
New Contributor III

Hello,

We are working on a Field Maps project which involve users' inspecting a pre-drawn parcel (polygon) and then adding points at specific features on the parcel. How can we pull in the parcelid from the polygon layer as the data points are created? This workflow will need to work offline. 

Thank You

Jessica

0 Kudos
10 Replies
DougBrowning
MVP Esteemed Contributor

Check out the FeatureSet functions.  

Looks like this.  Just a query into the other layer, then return the value (there will be just 1 found on my workflow so can use first).  For you you may want to use Intersects instead of filter then it will figure out the polygon spatially.

 

 

var sql = "PointID = '" + $feature.PointID + "'";
var tbl = Filter(FeatureSetByName($map,"Points", ['Supplementals'], false), sql);
return First(tbl).Supplementals

 

Intersects would be something like

var WYplots = Intersects($feature,Filter(FeatureSetByName($map,"WY Plots", ["PlotID"], false), sql));

Hope that helps

https://developers.arcgis.com/arcade/function-reference/data_functions/ 

 

 

RobertGeitner
New Contributor III

I was wondering if you could you use a pull data function, similar to Survey123, where I have a table with 'Scientific Name, Common Name, NRCS Plant Code' where if I identify one value, i.e. NRCS Plant Code, it would populate both the Scientific Name and the Common Name based on a table.  Would that be possible?? 

0 Kudos
DougBrowning
MVP Esteemed Contributor

Yes you can pulldata from the csv no problem.  We do this to lookup a wetland stability class or growth habit for example.

But we only store the code now then have a species table with all that other info in it. If you start baking in common name, growth habit, and all that into the form what happens when they change? Do you go try and fix that in thousands of data rows?  Nope just change in the one master table.  Better management that way.  Classic example is customer data.  Do you store address on every single order - nope just the number and then a table that has all that info.  Then you can change the address in just the one spot.

Also we share all of our species inventory, LPI, Gap, etc forms from our federal program.  If you are interested just pm me.

Hope that helps.

0 Kudos
JeremyBrown4
New Contributor II

@DougBrowning I am attempting to use the "Intersects" technique in field maps, but have been unable to get the field to populate when the new feature is created. I am wondering if there is something I am missing? The code works fine when used in a pop-up in map viewer, but it just keeps sowing up as null in field maps for some reason. It seems like there is no geometry to reference before the new feature is created? Does field maps need to be configured in some way to allow for this? Sorry if I am misunderstanding something about how this works, I am a novice at best. Here is the code I am using.

var parcels = FeatureSetByName($map,"Parcels")
var newPoint = Geometry($feature)
var result = intersects(newPoint, parcels)
return Proper((first(result).SITUS + ". " + first(result).CITY_SITUS + ", FL. " + first(result).ZIP_SITUS), 'everyword')

 

0 Kudos
DougBrowning
MVP Esteemed Contributor

I think it is Intersects (capital) I also not sure why you are doing geometry try this.

var parcels = FeatureSetByName($map,"Parcels")
var result = Intersects($feature, parcels)
return Proper((first(result).SITUS + ". " + first(result).CITY_SITUS + ", FL. " + first(result).ZIP_SITUS), 'everyword')

Also the layer needs to be in Field Maps of course and if you are offline the parcel needs to be in the offline area.

Hope that does it.  You can also make it faster by only calling the fields you need on line 1.

0 Kudos
JeremyBrown4
New Contributor II

Thanks @DougBrowning! That did the trick! The expression works now in the field maps mobile app, but not when creating features in map viewer, or with the edit widget in experience builder. Maybe they don't support that functionality yet? Thanks for the tip on only calling specific fields as well!

0 Kudos
DougBrowning
MVP Esteemed Contributor

It should work all over.  But you would not see it until you save then open the feature back up again.  

0 Kudos
JessicaWay1
New Contributor III

Is there a way to do this in SQL? We need to have Sync enabled for this form. "Calculate Field" does not accept Arcade expressions with Synce enabled. Or is there another way to use the query? Thank you for the quick reply

0 Kudos
DougBrowning
MVP Esteemed Contributor

It would not be a calculate field.  No such thing as calc field in Field Maps so not sure what you mean there.  This is just Arcade to show the value.  I use it a lot to figure a value then send it to a 123 form.  This could work for you as the form would add the points.

If you want to actually calc a field while offline then no it is not available yet.  That is coming soon in Attribute Rules.  There was a post on this but I cannot find it.

You can go old school and just run a script at night to calc it using spatial join.

Hope that helps

 

0 Kudos