Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in FeatureLayerCollection.query_domains

See original GitHub issue

In arcgis python api version 1.6.2, the FeatureLayerCollection.query_domains method generates an error. For example:

item = gis.content.get('ITEM_ID')
flc = FeatureLayerCollection.fromitem(item)

produces this error:

TypeError                                 Traceback (most recent call last)
<ipython-input-30-31345fbf23ab> in <module>
----> 1 flc.query_domains([0])

~/anaconda3/envs/geo/lib/python3.7/site-packages/arcgis/features/ in query_domains(self, layers)
   1909         """
-> 1910         if not isinstance(layers (tuple, list)):
   1911             raise ValueError("The layer variable must be a list.")
   1912         url = "{base}/queryDomains".format(base=self._url)

TypeError: 'list' object is not callable

The error appears to be caused by a missing comma after layers in line 1910 of

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

mikiekellycommented, Dec 20, 2019

As a workaround you can access domains this way:

from arcgis.gis import GIS

def process_layers_or_tables(layer_or_table):
    print(f'{}: {layer_or_table.url}')
    for field in
        print(f'\t{} - {field.alias} - {field.type}')
        if 'domain' in field and field.domain is not None:
            print(f'\t\tDomain associated with field')
            if field.domain.type == 'codedValue':
                for coded_value in field.domain.codedValues:
                print(f'Not coded value domain: {field.domain}')

gis = GIS()

feature_layer = gis.content.get('90cf22bcbb30499c912264f5305be5b8')

for layer in feature_layer.layers:

for table in feature_layer.tables:
jlishnunncommented, Dec 20, 2019

Thank you @mikiekelly

I re-purposed your function to create a list of coded domain values

def layer_or_table_domain_values(layer_or_table, field_name):
    arcpy.AddMessage(f'{}: {layer_or_table.url}')
    field_names = [ for field in]
    for field in
        if field_name ==
            if 'domain' in field and field.domain is not None:
                arcpy.AddMessage('Domain associated with field')
                if field.domain.type == 'codedValue':
                    domain_values = [ for coded_value in field.domain.codedValues]
                    arcpy.AddMessage(f'Not coded value domain: {field.domain}')
Read more comments on GitHub >

github_iconTop Results From Across the Web

What's new in version 2.0.0 | ArcGIS API for Python
FeatureLayerCollection. Fixes BUG-000134934 where query_domains() fails with The requested layer (layerId: queryDomains) was not found. (Error Code: 400).
Read more >
featureLayerCollection overwrite "Job failed" - Esri Community
Hi. I am trying to update/overwrite a hosted feature layer, following the logic given near the end of a tutorial on learn.arcgis (...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found