Hi All,
I want an ArcMap definition query so that the layer only shows features based off of what the computer login user name is.
I have a field named USERNAME that would contain different user names. Then I would use the definition query to only show and label those features that have the same computer login name. For example: USERNAME = SYSTEM_USER.
I can get user name and PC name to label using Python but I want to query on user name and that uses SQL.
Can it be done?
Thanks,
David
I am afraid this can't be done as SQL expression doesn't support advanced syntax like label expressions.
But you could write a simple python addin extension A Python Addin Extension
Which can be used to apply to definition query to your layer something like below:
import arcpy import pythonaddins import getpass class ExtensionClass1(object): """Implementation for pyaddins_addin.extension2 (Extension)""" def __init__(self): # For performance considerations, please remove all unused methods in this class. self.enabled = True def startup(self): pass def applyDefQuery(self): lyr = arcpy.mapping.ListLayers(arcpy.mapping.MapDocument("CURRENT"))[0] if lyr.supports("DEFINITIONQUERY"): lyr.definitionQuery = "USERNAME='{0}'".format(getpass.getuser().upper()) arcpy.RefreshActiveView() return def newDocument(self): self.applyDefQuery() return def openDocument(self): self.applyDefQuery() return
Do you think this is doable in the web world? (Using ArcGIS Server -- Web application builder) ? thoughts?
my initial thought is that this sounds like a job for SOIs...