Enable Attribute Rules (Data Management)

Summary

Enables one or more attribute rules in a dataset

Usage

  • New attribute rules are enabled by default upon creation or import, but if you disabled them using the Disable Attribute Rules tool, you can use this tool to re-enable the rules so that they will be enforced again.

  • You can use this tool in conjunction with the Disable Attribute Rules tool to disable and re-enable rules as needed.

  • If you specify both a rule name and a rule type when running this tool, upon execution, the tool will verify that the type of rule specified matches the rule type specified. If they do not match, the rule will not be enabled.

Syntax

EnableAttributeRules(in_table, names, {type})
ParameterExplanationData Type
in_table

The table or feature class that contains the attribute rule to be enabled.

Table View
names
[names,...]

The names of the rules to enable for the dataset.

String
type
(Optional)

Specifies the type of attribute rules to enable. The tool will verify that the type of rule specified in this parameter matches the rule type specified. If they do not match, the rule will not be enabled.

  • CALCULATIONEnable a calculation rule.
  • CONSTRAINTEnable a constraint rule.
  • VALIDATIONEnable a validation rule.
String

Derived Output

NameExplanationData Type
out_table

The updated input table with an attribute rule enabled.

Table View; Raster Layer; Mosaic Layer

Code sample

EnableAttributeRules example 1 (Python window)

Enable two specific calculation attribute rules from a feature class.

import arcpy
arcpy.EnableAttributeRules_management("C:\\MyProject\\MyDatabase.sde\\pro.USER1.campusData", 
                                      "Rule A;Rule B", "CALCULATION")
EnableAttributeRules example 2 (Python window)

Enable calculation and constraint attribute rules from a feature class.

import arcpy
arcpy.EnableAttributeRules_management("C:\\MyProject\\MyDatabase.sde\\pro.USER1.campusData", 
                                      "Calculation Rule A;Constraint Rule A")
EnableAttributeRules example 3 (Python window)

Use arcpy.Describe to enable all constraint rules that are currently disabled.

import arcpy
fc = "C:\\MyProject\\MyDatabase.sde\\pro.USER1.campusData"
desc = arcpy.Describe(fc).attributeRules
for rule in desc:
    if rule.isEnabled == False and rule.type == "esriARTConstraint":
        print("Enabling rule: {}".format(rule.name))
        arcpy.EnableAttributeRules_management(fc, rule.name)

Environments

Licensing information

  • Basic: No
  • Standard: Yes
  • Advanced: Yes

Related topics