Enforce quality during data collection

The first two attribute rules that you'll create will enforce data integrity as the data is collected. You'll create a constraint rule to ensure that none of the test fields are left with null values and you'll create an immediate calculation rule to automatically generate the inspection test results. This will eliminate the need for mobile workers to manually compute the test results. These two attribute rules will save time and prevent errors.

Prepare the street light data for attribute rules

To begin, you will review the street light data and its attributes. You'll ensure that the feature class has Global IDs enabled, a requirement for all attribute rules, as well as Editor tracking enabled, a requirement for some attribute rules.

  1. Download the WhiteRockCity project package.

    A file named WhiteRockCity.ppkx is downloaded to your computer.

    Note:

    A .ppkx file is an ArcGIS Pro project package and may contain maps, data, and other files that you can open in ArcGIS Pro. Learn more about managing .ppkx files in this guide.

  2. Locate the downloaded file on your computer and double-click WhiteRockCity.ppkx to open it in ArcGIS Pro. If prompted, sign in with your ArcGIS account.
    Note:

    If you don't have access to ArcGIS Pro or an ArcGIS organizational account, see options for software access.

    The project opens with the White Rock City map active. The map contains the street light data you will be working with.

    Map of White Rock City with street light data

    Note:

    The street light data is from the White Rock Open Data Portal.

  3. In the Contents pane, right-click the Street Lights layer and click Attribute Table.

    Attribute Table option in the Street Lights layer's context menu

    The attribute table appears.

  4. Scroll horizontally through the table and review the Hammer Test, Pole Condition, Wiring Condition, Panel Condition, and Inspection Test Results fields.

    Test fields in the attribute table

    You will use these fields to create and apply the attribute rules. The value range for each test is between 0 and 5, where 0 means the pole failed the test and 5 means it is in excellent condition. The Inspection Test Results field records the mean of the four test results.

  5. Close the attribute table.

    Before you create any attribute rules, you'll ensure that the feature class is configured correctly. Global IDs must be enabled on a feature class before attribute rules can be created.

  6. In the Catalog pane, expand Databases and whiterockcity.gdb.
  7. Right-click the Street_Lights feature class and click Manage.

    Manage option in the Street_Lights feature class's context menu

    The Feature Class Properties window opens to the Manage tab. The Global IDs check box is already checked.

    Global IDs are a requirement for all types of attribute rules. However, validation and batch calculation attribute rules additionally require that Editor tracking be enabled. You must create a validation rule later in this tutorial, so you'll enable this functionality as well.

  8. Check the Editor tracking check box.

    Editor tracking checked in the Feature Class Properties pane

  9. Click OK.

    The Street_Lights feature class is now ready to receive attribute rules.

Create a constraint rule

Next, you will ensure all newly created features have the Hammer test, Panel condition, Wiring condition, and Pole condition fields populated. These values are used to determine the overall condition of street light poles, so it is important that none are left with null values. You will create a constraint attribute rule and enforce it during data editing.

Constraint attribute rules are used to ensure that attribute conditions are met. They return an error message when the conditions are not met. The rule evaluation occurs immediately during the editing process, when new features are added, or when existing features are updated or deleted.

  1. In the Contents pane, right-click Street Lights, point to Data Design, and click Attribute Rules.

    Attribute Rules in the Data Design context menu

    The Attribute Rules view appears. The three rule types are listed at the top of the view: Calculation, Constraint, and Validation.

  2. Click the Constraint tab, and click Add Rule.

    Constraint tab and Add Rule button in the Attribute Rules view

    A table and the New Rule pane appear.

  3. In the New Rule pane, for Rule Name, type Check for null values.
  4. For Description, type Returns features where the Hammer Test, Pole Condition, Wiring Condition, or Panel Condition fields are null.

    Next, you'll write an expression to define the rule.

  5. Click the Expression button.

    Expression button

    The Expression Builder window appears. Language is set to Arcade. You'll use the IsEmpty() function and an if statement to build an Arcade expression that checks if the values in your fields of interest are null.

  6. In the Expression box, copy and paste the following:
    // Check if the values in the Hammer Test, Pole Condition, Wiring Condition, or Panel Condition fields are null (empty).
    if  (IsEmpty($feature.HammerTest) ||
    isEmpty($feature.PoleCond) ||
    isEmpty($feature.WiringCond) ||
    isEmpty($feature.PanelCond))
    
    // If any of the fields above are null, return false.
    return false
    
    // Otherwise, return true.
    return true

    This expression translates to the following: If the Hammer Test field is null, or if the Pole Condition field is null, or if the Wiring Condition field is null, or if the Panel Condition field is null, return false. Otherwise (if all fields are properly populated), return true.

    Expression Builder window

    Note:

    For more information about Arcade functions, refer to the Arcade Function Reference page.

  7. Click OK.

    The expression appears in the Check for null values pane. Next, you'll define the error number and message that will appear when the rule is violated.

  8. For Error Number, type 101.
  9. For Error Message, type Empty fields: Fill in the Hammer Test, Pole Condition, Wiring Condition, or Panel Condition fields with the test results.

    Finally, you'll determine when the rule will be evaluated.

  10. For Triggers, check Insert and Update.

    Triggers

    The rule will automatically be evaluated when a new feature is created or an existing one is updated.

  11. On the ribbon, on the Attribute Rules tab, in the Attribute Rules group, click Save.

    Save button on the Attribute Rules ribbon tab

    Your first attribute rule is created and will take effect the next time a feature is created or edited in the Street Lights layer.

Create an immediate calculation rule

Next, you'll create an immediate calculation rule to calculate the Inspection Test Results field. Calculation attribute rules are used to automatically populate attribute values. Your new rule will calculate the average of the four test fields to populate the Inspection Test Results field.

  1. At the top of the Attribute Rules view, click the Calculation tab.

    There are two type of calculation rules. For immediate calculation rules, the evaluation occurs immediately, during the editing process. For batch calculation rules, the evaluation occurs at a specified time. For this project, you'll be recording the quality of newly created light poles, so you'll create an immediate calculation rule that will evaluate as each new feature is created.

  2. Click the arrow on the Add Rule button and click Add Immediate Calculation Rule.

    Add Immediate Calculation Rule

  3. In the New Rule pane, for Rule Name, type Calculate final inspection test results.
  4. For Description, type Calculates the mean of the Hammer Test, Pole Condition, Wiring Condition, and Panel Condition values to determine the overall inspection test results.

    Next, you'll specify which field should receive the calculation.

  5. For Field, choose Inspection_Results.

    Field set to Inspection_Results

    Next, you'll write an Arcade expression to define the rule. You'll use the Mean() function to calculate an average of all test results.

  6. Click the Expression button.
  7. In the Expression Builder window, in the Expression box, copy and paste the following:
    // Return the mean of four test values
    Mean($feature.HammerTest,$feature.WiringCond,$feature.PanelCond,$feature.PoleCond)

    Expression Builder

  8. Click OK.
  9. For Triggers, check Insert and Update.
  10. On the ribbon, on the Attribute Rules tab, in the Attribute Rules group, click Save.

    So far, you have created two attribute rules. You created a constraint rule to ensure the four test fields are not null and an immediate calculation rule to automatically populate the Inspection Test field. In the next part, you will test the editing experience with the two new attribute rules.

Create a feature to test the attribute rules

After creating constraint and immediate calculation attribute rules, it's time to test the editing experience. You must make sure the rules operate as you intended before asking others to collect data with them. You'll create a pole feature to test the editing experience.

  1. Above the Attribute Rules view, click the White Rock City Map tab to return to the map view.

    White Rock City Map tab

  2. On the ribbon, click the Edit tab. In the Features group, click Create.

    Create button on the Edit ribbon tab

    The street light pole feature that you'll create is based on information previously collected by a mobile worker. It has the following properties:

    • Bulb type—LED Rope
    • Location—Intersection of Columbia Ave and Centre St.
    • Hammer Test—3
    • Pole Condition—2
    • Wiring Condition—5
    • Panel Condition—5
  3. In the Create Feature pane, click the LED Rope template.

    LED Rope template in the Create Features pane

  4. On the map, zoom to and click near to the intersection of Columbia Ave and Centre St.

    Intersection of Columbia Ave and Centre St

    Note:

    If you can't find the correct location, you can choose a different intersection.

    A new feature does not appear on the map. Instead, an error message appears in the Create Features pane, letting you know the feature was not created because it violates the constraint attribute rule. The message is the one you wrote when you created the rule.

    Error message in the Create Features pane

    The message asks you to fill in the test fields with the test results. You'll comply with the rule so you can create the feature.

  5. On the LED Rope template, click the arrow button.

    Arrow button on the LED Rope template

  6. For Hammer Test, type 3. For Pole Condition, type 2. For Wiring Condition, type 5. For Panel Condition, type 5.

    Test field results

  7. Click the map again to place the feature.

    The new street light feature was successfully created. In the Create Features pane, the error message is replaced by a completed message.

    Completed message in the Create Features pane

    On the map, the point feature appears blue instead of the expected purple color because it is selected. Do not clear the selection.

  8. On the ribbon, on the Edit tab, in the Manage Edits group, click Save.

    Save button on the Edit ribbon tab

  9. In the Save Edits window, click Yes.

    The constraint attribute rule successfully prevented the creation of a new street light feature that did not have valid test values.

  10. Close the Create Features pane.

    Next, you will test the calculation rule. If it works properly, it should automatically populate the Inspection Test Results field with the average of the four test values.

  11. On the ribbon, on the Edit tab, in the Selection group, click Attributes.

    Attributes button on the Edit tab of the ribbon

    The Attributes pane appears.

    Note:

    Make sure the street light feature at Columbia Ave and Centre St is selected.

  12. In the Attributes pane, locate the Inspection Test Results field.

    The field is set to 3.75. This is the mean of the values in the Hammer Test, Pole Condition, Wiring Condition, and Panel Condition fields.

    Inspection Test Results field in the Attributes pane

    The immediate calculate attribute rule was successful in populating the Inspection Test Results field.

  13. On the ribbon, on the Edit tab, in the Selection group, click Clear.

The constraint rule increased the quality of your new data by stopping the creation process until important fields were properly populated. The immediate calculation rule improved performance and accuracy by automatically populating the Inspection Test Results field, which would otherwise be calculated manually. Next, you will switch focus from data entry to assessing the quality of your exiting data.


Find features that failed the inspection test

You will create a validation rule to determine which pole features failed the inspection test. Validation attribute rules are used to ensure that attribute conditions are met on existing features. Rather than running automatically, validation rules are evaluated by the user through the Error Inspector view. When rules are violated, error features are created for review.

Create a validation rule

You will create a validation attribute rule to identify street light poles that failed inspection. According to your project requirements, an inspection test is considered failed when the Inspection Test Results value is less than 2. It is important to know which poles failed the inspection test so the city can allocate the appropriate resources to retest, repair, or replace them.

  1. Above the map, click the Attribute Rules: Street Lights tab to open the Attribute Rules view.
  2. Click Validation and click Add Rule.

    Validation tab and Add Rule button in the Attribute Rules view

  3. In the New Rule pane, for Rule Name, type Check for light pole features that failed inspection.
  4. For Description, type Returns features with inspection test values less than 2.
  5. Click the Expression button. In the Expression Builder window, in the Expression box, copy and paste the following:
    if ($feature.Inspection_Results < 2)
    
    return false
    
    return true
  6. Click OK.

    Rule Name, Description, and Expression

  7. For Error Number, type 102.
  8. For Error Message, type Inspection test failed: This feature did not pass inspection.
  9. For Severity, choose 3.

    The Severity property indicates how important it is to fix the error. A value of 1 is considered high severity and 5 is considered low severity.

    Error Number, Message, and Severity

  10. On the ribbon, on the Attribute Rules tab, in the Attribute Rules group, click Save.
  11. Close the Attribute Rules view.
  12. On the Quick Access Toolbar, click Save.

    Save button on the Quick Access Toolbar

Evaluate the validation rule

Next, you will test the validation rule. You evaluated the constraint and immediate calculation rules during data editing. However, the validation rule runs on demand against existing features, so you will use the Error Inspector view to evaluate any street light features that have failed inspection.

  1. On the ribbon, click the Edit tab. In the Manage Edits group, click Error Inspector.

    Error Inspector button on the Edit ribbon tab

    The Error Inspector view appears. The message (Please select a map that contains error layers) indicates that you must create error layers before you can begin. The error inspection process will evaluate validation and batch calculation attributes rules and store any errors that it finds in error layers. You'll add error layers for the Street Lights layer.

  2. In the Contents pane, right-click Street Lights and click Add Error Layers.

    Add Error Layers option in the layer's context menu

    Note:

    If the Add Error Layers option is unavailable, close and re-open ArcGIS Pro.

    A new group layer named Error Layers appears in the Contents pane. An empty table appears in the Error Inspector view. The Source is set to the Error Layers group layer that you just created.

    Source set to Error Layers

    Before you evaluate the validation attribute rule for errors, you'll ensure that the correct rule and all features will be evaluated.

  3. In the Contents pane, right-click Street Lights and click Zoom To Layer.
  4. On the Error Inspector view's toolbar, click the arrow next to Evaluate Rules.
  5. For Rule Type, ensure that Validation is checked.

    Evaluate Rules settings

    You don't have any batch calculation attribute rules in this project, so it does not matter if Batch Calculation is checked or unchecked.

  6. Click Evaluate Rules.

    Two error features appear in the table.

    Error Inspector with two error features

    The error features are street light poles that had a score less than 2 and so failed inspection. On the map, they appear as red squares.

    Error features on the map

    Next, you will address the two errors.

Inspect and address errors

You will review and resolve the two errors revealed by the validation rule. You'll provide new test results for one and mark the other as an exception so it will be available for a follow-up review later.

  1. In the Error Inspector view, click the row header of the first error feature to select it.

    Row header for first error feature

  2. If necessary, re-open the Attributes pane.

    In the Attributes pane, one feature is shown selected in the Error Layers: Point Errors layer. The error number and message that you wrote earlier appear in the Attributes table.

    Error feature in the Attribute pane

    Later, other people in your office will be reviewing errors, so providing information about what caused the error and how to fix it is important.

  3. On the Error Inspector view's toolbar, click Features.

    Features button

    In the Attributes pane, a new selection appears for feature 161 in the Street Lights layer. This is the feature that caused the error.

  4. In the Attributes pane, click 161. Scroll through the Attributes table to find the Inspection Test Results field.

    Street Lights feature 161 in the Attributes pane

    The Inspection Test Results value is 1.75, which is less than the passing score of 2. According to these test results, street light 161 failed inspection. The Comments field contains no information about why the pole was in poor condition.

    To resolve this issue, you sent a mobile worker to re-inspect the street light pole. They returned with new and more accurate test results for the wiring and panel tests.

  5. In the Attributes pane, for Wiring Condition, type 3. For Panel Condition, type 3.

    Wiring and Panel Condition values updated

    The immediate calculation attribute rule you created earlier in the tutorial comes into effect during feature updates, so the Inspection Test Results field updates to 2.75.

  6. In the Attributes pane, click Apply.

    You'll switch the selection to the second error feature and its associated street light feature.

  7. In the Error Inspector view, select the second row. On the view's toolbar, click Features.
  8. In the Attributes pane, click 774.

    The Inspection Test Results value is 1.5, not high enough to pass inspection.

    Street Lights feature 774 in the Attributes pane

    There are no mobile workers available to check this pole, so you'll mark the error as an exception until you can get more information about it.

  9. In the Error Inspector view, right-click the row header for the second row and click Mark As Exception.

    Mark As Exception in the error feature's context menu

  10. On the view's toolbar, click Evaluate Rules.

    The first error feature disappears, since it no longer fails the validation rule. The second error feature remains. It has a green symbol in the Exception column to indicate it is marked as an exception.

    Exception column in the Error Inspector table

    Because this error feature is marked as an exception, it will persist across multiple evaluation sessions. This allows you to keep track of the feature until the pole has been reassessed or repaired.

  11. Close the Error Inspector view and the Attributes pane.
  12. On the ribbon, on the Edit tab, in the Selection group, click Clear.
  13. In the Manage Edits group, click Save. In the Save Edits window, click Yes.
  14. On the Quick Access Toolbar, click Save.

You created and applied a validation rule to identify two light pole features that failed inspection. You corrected the test results of one feature and marked the other one as an exception. The validation rule allowed you to assess the quality of your data and correct any data issues.

In this tutorial, you created and tested three attribute rules to improve the quality of street light data in the city of White Rock. You created a constraint rule to ensure all new features have the four test fields properly populated with test result values. You created an immediate calculation rule to automatically populate the Inspection Test Results field with the mean of the four test results. Finally, you created a validation rule to identify any street light poles that did not pass inspection. Your efforts have improved the quality of the Street Lights layer, which will in turn help to improve the quality of the physical street lights in the city of White Rock.

You can find more tutorials in the tutorial gallery.