Select to view content in your preferred language

attribute 'field is required' property

2883
1
09-15-2011 02:26 AM
by Anonymous User
Not applicable
You can set the field_is_required property when creating a field (via diagrammer or management tools/add field yet I don't see this actually being enforced when i attempt to edit the data. Is this a known issue? Can anyone actually confirm they have it working?

My understanding is that this will 'force' a newly added record to include the 'required' field is populated, similar in concept to the is_nullable property that you can set.

See http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000047000000 for more info on the tools syntax.

Brad
0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor
I believe the web help is incorrect where it states:

REQUIRED �??The field is a required field. This means new records must contain a value for the field. Required fields are permanent and can not be deleted.

'This means new records must contain a value for the field' should be removed.  Setting a field to 'Required' will make it permanent, and disable the option to delete it. 

As a workaround you could create a script to check all 'required' fields for empty values.  Here is an example:

import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"

fc = "Req_Test"

lstFields = arcpy.ListFields(fc, "*")
for field in lstFields:
    if field.required == True:
        field_name = field.name
        rows = arcpy.SearchCursor(fc, "", "", field_name)
        for row in rows:
            val = row.getValue(field_name)
            if val == " ":
                print field_name + " contains a blank row for OBJECTID " + str(row.OBJECTID) 


del row, rows
0 Kudos