Select to view content in your preferred language

fetch attribute from table

56
4
9 hours ago
dsinha
by
Frequent Contributor

Hello, 

I have a data collection layer for FieldMaps and a table stored on the Portal. Based on the Parcel ID on the data collection layer, I am trying to populate the owner address in the collection layer from the table. I am basing the Arcade expression on this post.

dsinha_0-1761237555014.png

var OwnerAdd = $feature.ma
var table = FeatureSetByPortalItem(Portal('https://xyz/portal/'),'61fe20149cd74fff91209b580f841145', ['parcelid', 'owner'])
var filteredTable = Filter(table, "parcelid = @OwnerAdd")
var result = First (filteredTable)
if(!IsEmpty(result)){
  return result.owner
}

When I test it , it provides a null output and it does not work in the form.

Any help would be appreciated. 

0 Kudos
4 Replies
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @dsinha,

Have you used the Console() function to see if there is any result for the feature? You can also verify that there are records by using the Count() function in conjunction with the Console() to see if there are any records that are returned by your query. It could be that either the query is resulting in no records returning or that there is something else going on.

Did you double check that the field name(s) exist and you are filtering for the correct data? Ex. ("ParcelPin = '1000000'") vs (ParcelPin = 1000000"). If you use the console then it should help troubleshoot the issue.

0 Kudos
dsinha
by
Frequent Contributor

Hi @RPGIS, thanks for making me aware of this option.

Should I run the console function on all the var functions and note their output?

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @dsinha.

It is recommended should the desired result not be what you want. It could help you troubleshoot where there are issues in your code.

0 Kudos
DougBrowning
MVP Esteemed Contributor

One change to make is you have to check empty before using first.  The sample code they have out there is wrong.  I told them but it never got changed.  If you call first on an empty list it fails.

For filter not sure why the @ symbol is in there?  I do it like this with a sql in a var and it works.  Also note wrap filter around the FeatureSet call is faster since its one call not 2.  Also set return geo to false is faster.

var EvaluationID = Concatenate($feature.PlotID, "_", text(ToLocal($feature.FieldEvalDate), "Y-MM-DD"))

var sql = "EvaluationID = '" + EvaluationID + "'";
var tbl = Filter(FeatureSetByName($map,"Site Evaluation", ['EvaluationID'], false), sql);

hope that does it.

0 Kudos