Select to view content in your preferred language

Connecting ID Data to Attribute table

968
4
Jump to solution
08-02-2023 01:18 PM
klewis47
Emerging Contributor

Hi, 

So I have a trigger that when you create a polygon (each has its own ID) it will add the shape area and other data to a relational table using var FeatureSetByName, dictionaries and the attribute rules. My issue is that occasionally the user might want to data directly from that relational table through the add table. What i'm trying to set up is that if there was already a polygon created with an id of 79 the user could add a row to that table and write in the 79 as the id and the area of that polygon will automatically load into the table. My thing is that since the attribute rules are based on triggers a change won't be made until something within the polygon is changed. Does anyone know how I could get the table to automatically load the data for the same ID? 

klewis47_0-1691007394462.png

^ for example I want the null value in the second row to be the same value as the one above it.

1 Solution

Accepted Solutions
JohannesLindner
MVP Alum

You have created an Attribute Rule on the fc that writes to the table. As you said, that triggers only when you edit the fc. To get the same effect when you edit the table, you have to create another Attribute Rule there that reads from the fc:

// Calculation Attribute Rule on the table
// Field: empty
// Triggers: Insert, Update

// load the polygon fc
var polygons = FeaturesetByName($datastore, "Polygons")

// find the correct polygon
var id = $feature.PolygonID
var poly = First(Filter(polygons, "PolygonID = @ID"))
if(poly == null) { return }

// and return its values:
return {
    result: {
        attributes: {
            Field1: poly.Field1,
            Field2: poly.Field2,
            Field3: poly.Field3,
        }
    }
}

Have a great day!
Johannes

View solution in original post

0 Kudos
4 Replies
JohannesLindner
MVP Alum

You have created an Attribute Rule on the fc that writes to the table. As you said, that triggers only when you edit the fc. To get the same effect when you edit the table, you have to create another Attribute Rule there that reads from the fc:

// Calculation Attribute Rule on the table
// Field: empty
// Triggers: Insert, Update

// load the polygon fc
var polygons = FeaturesetByName($datastore, "Polygons")

// find the correct polygon
var id = $feature.PolygonID
var poly = First(Filter(polygons, "PolygonID = @ID"))
if(poly == null) { return }

// and return its values:
return {
    result: {
        attributes: {
            Field1: poly.Field1,
            Field2: poly.Field2,
            Field3: poly.Field3,
        }
    }
}

Have a great day!
Johannes
0 Kudos
klewis47
Emerging Contributor

(Deleted)

0 Kudos
JohannesLindner
MVP Alum
  • check the filter expression in line 6 (probably a copy/paste error)
  • check that both tables actually have a field called "shape_area"
  • just calculate the Area():
'shape_area': Area(poly),

 


Have a great day!
Johannes
0 Kudos
klewis47
Emerging Contributor

Got it working, thank you!

0 Kudos