arcpy find which fields use domain code example

Example: arcpy find which fields use domain

import arcpy


gdb = r'<YOUR GDB HERE>'
arcpy.env.workspace = gdb

# Update domain search here
domainList = ['piPipeMaterial', 'piControlValveType']

# Find which fields are using domains in the domainList
for domain in domainList:
    print("Looking for '" + domain + "' domain...")
    fds = arcpy.ListDatasets(feature_type='feature')
    for fd in fds:
        print('Searching ' + fd + '...')
        fcs = arcpy.ListFeatureClasses(feature_dataset=fd)
        for fc in fcs:
            fields = arcpy.ListFields(fc)
            for field in fields:
                if field.domain == domain:
                    print('Found field ' + field.name + ' in feature class ' + fc + ' using ' + domain)
                    print('----')
        print('----------')