Arcade Script For Layer To Layer Calculation

191
1
Jump to solution
07-17-2024 08:34 AM
JonFrederiksen
New Contributor

I am wanting to populate a field on one layer from a field with the same name on another layer based on a common global ID and am having difficulty figuring out the arcade code to do so.  I do not have much experience with this kind of coding using arcade.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

If you have a relationship set up between the two layers, you can use this syntax to get an attribute from the other layer

var related = FeatureSetByRelationshipName($feature, 'your relationship name');

if (Count(related) > 0) {
  var record = First(related);
  return record.theField;
}

If not, you can use this syntax to get the other feature.

var asset_id = $feature.GUID
var fs = FeatureSetByPortalItem(
  Portal('yourPortal'),
  'itemId',
  0,
  ['*'],
  false
);
var related = First(Filter(fs, "GlobalID = @asset_id"))

if(related != null) return related.theField

View solution in original post

1 Reply
KenBuja
MVP Esteemed Contributor

If you have a relationship set up between the two layers, you can use this syntax to get an attribute from the other layer

var related = FeatureSetByRelationshipName($feature, 'your relationship name');

if (Count(related) > 0) {
  var record = First(related);
  return record.theField;
}

If not, you can use this syntax to get the other feature.

var asset_id = $feature.GUID
var fs = FeatureSetByPortalItem(
  Portal('yourPortal'),
  'itemId',
  0,
  ['*'],
  false
);
var related = First(Filter(fs, "GlobalID = @asset_id"))

if(related != null) return related.theField