Skip To Content

Enable Attribute Rules

Summary

Disables one or more attribute rules from a dataset

Usage

  • New attribute rules are enabled by default upon creation or import, but if you have 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.

  • Attribute rules are only supported on enterprise geodatabase datasets.

  • 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_management (in_table, names, {type})
ParameterExplanationData Type
in_table

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

Table View
names
[names,...]

The names of the rules to enable on the dataset.

String
type
(Optional)

The type of attribute rules to enable. If a value is specified for this parameter, the tool will verify that the type of rule specified matches the rule type of the rule name specified. If they do not match, the rule will not be enabled.

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

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

  • ArcGIS Desktop Basic: No
  • ArcGIS Desktop Standard: Yes
  • ArcGIS Desktop Advanced: Yes

Related topics