Select to view content in your preferred language

How to use model builder to apply an attribute rule to feature classes when table name is in the expression?

290
1
10-14-2022 11:03 AM
V1212
by
New Contributor II

Hi, 

I am trying to apply an attribute rule to multiple feature classes using iterate feature classes in model builder. I get an error message because expression has a table name that's different to the name of the feature classes I'm trying to add the rule to. 

ERROR 002717: Invalid Arcade expression, Arcade error: Table not found Table_4546, Script line: 2, SCRIPTEXPRESSION (row 2) [Table_4546]

Is there any in line substitution I can do to make it work? 

Thanks in advance! 

0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor
  • Get your Table name as variable (put "%" around the name in ModelBuilder)
  • Use Calculate Value
# Expression
generate_arcade_expression(%TableName%)

# Code Block
def generate_arcade_expression(table_name):
    return f"""
        var fs = FeaturesetByName($datastore, "{table_name}")
        var fs_intersect = Intersectcs(fs, $feature)
        //...
    """
  • Use the output of Calculate Value as Arcade Expression for Add Attribute Rule.

Have a great day!
Johannes
0 Kudos