# tag.get(propertyObject) not working

**URL:** <https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275>\
**Category:** Ignition\
**Created:** [March 8, 2018, 1:06pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275 "2018-03-08T13:06:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [March 8, 2018, 1:06pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/1 "2018-03-08T13:06:58Z")

</div>

Hello all,  
I have been attempting to pull specific properties out of tags that are returned by system.tag.browseConfiguration().  
Following the post [here](http://forum.inductiveautomation.com/t/tagconfiguration-get-string-not-working/16140) I made the following script:

```auto
"""
This example will browse the root of the Tag Provider named "default".
For each tag found, prints the non-default properties.
"""
from com.inductiveautomation.ignition.common.sqltags.model import TagProp
# Specify the folder to browse. Modify this line to filter on a specific folder. 
folderPath = "CF1/CF1_BowlSpeed"
db = TagProp.HistoricalDeadband
histEnabled = TagProp.HistoryEnabled
# Start a non-recursive browse, and stores the configuration data in a variable
tagConfig = system.tag.browseConfiguration(folderPath, False)
# Iterate through the configuration data
for tag in tagConfig:
    #print "--------------------------------------------------------------------"
    propList = tag.getProperties()
    print "Property '%s' has a value of '%s'" % (str(db), tag.get(db))
    print "Property '%s' has a value of '%s'" % (str(histEnabled), tag.get(histEnabled))
    # Iterate through the list of properties
    for prop in propList:
        #Print the property name and value.
        if prop == db:
        	print "Property '%s' has a value of '%s'" % (prop, tag.get(prop))
        elif prop == histEnabled:
        	print "Property '%s' has a value of '%s'" % (prop, tag.get(prop))

```

The output is the following:

```auto
Property 'HistoricalDeadband' has a value of 'None'
Property 'HistoryEnabled' has a value of 'None'
Property 'HistoricalDeadband' has a value of '15.0'
Property 'HistoryEnabled' has a value of 'True'

```

My question is how is it that one method returns ‘None’ while the other method returns a value?  
I would really like to pull the exact properties I want and not depend on the getProperties() method.  
Thanks

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 8, 2018, 1:20pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/2 "2018-03-08T13:20:29Z")

</div>

Hmm. Good question 😕

I think basically the `Property` objects you get from the `TagProp` enum don’t implement equality the way a `Property` should, so when you call `get` with it on the `PropertySet` (each `TagConfiguration` is a `PropertySet`) it doesn’t find it as a key. Seems like a bug on our side.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 8, 2018, 1:24pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/3 "2018-03-08T13:24:54Z")

</div>

Try using properties from `com.inductiveautomation.ignition.common.tags.config.TagConfigProps` instead of the `TagProp` enum you’re using.

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [March 8, 2018, 1:38pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/4 "2018-03-08T13:38:11Z")

</div>

> [@Kevin.Herron](#):
>
> Try using properties from com.inductiveautomation.ignition.common.tags.config.TagConfigProps instead of the TagProp enum you're using.

That fixed it. Can you please give me a link to that in the API docs. I can only find com.inductiveautomation.ignition.common.sqltags.\* and not the specific class you listed. I'm probably just not looking in the right place.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 8, 2018, 1:51pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/5 "2018-03-08T13:51:16Z")

</div>

There’s no API docs to link you to, as far as I know…

It’s part of the same JAR file as the `TagProp` enum, so you should be able to find it by its class name if it has docs.

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [March 8, 2018, 1:58pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/6 "2018-03-08T13:58:45Z")

</div>

> [@Kevin.Herron](#):
>
> so you should be able to find it by its class name if it has docs.

It does not unfortunately.  
But it seems that all of the properties I have tried so far that are in the class **_TagProp_** have worked. Thanks for your help!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 8, 2018, 2:42pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/7 "2018-03-08T14:42:16Z")

</div>

Turns out the members of the original `TagProp` enum each have `.property()` method you can call to get a usable `Property` as well.

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [March 29, 2018, 9:00pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/8 "2018-03-29T21:00:29Z")

</div>

Okay. I’m trying to pull out the historical scanclass for each tag configuration, but I get the following error:

Traceback (most recent call last):

```auto
  File "<event:mousePressed>", line 1, in <module>
  File "<custom-function updateTable>", line 44, in updateTable
TypeError: getOrDefault(): 1st arg can't be coerced to com.inductiveautomation.ignition.common.config.Property

Ignition v7.9.5 (b2017111615)
Java: Oracle Corporation 1.8.0_151

```

Here is the relevant code:

```auto
	from com.inductiveautomation.ignition.common.sqltags.model import TagProp
	from com.inductiveautomation.ignition.common.tags.config import TagConfigProps
	from com.inductiveautomation.ignition.common.config import Property
	# Specify the folder to browse. Modify this line to filter on a specific folder. 
	propDict = {}
	propList = []
	folderPaths = ["aMemoryTags"]
	headers = ["Tag Path","Documentation","Data Type","Engineering Unit","History Enabled","Historical Deadband","Historical Scanclass","Engineering Low", "Engineering High"]
	db = TagConfigProps.HistoricalDeadband
	histSC = TagConfigProps.HistoricalScanclass
	histEnabled = TagConfigProps.HistoryEnabled
	engLow = TagConfigProps.EngLow
	engHigh = TagConfigProps.EngHigh
	engUnit = TagConfigProps.EngUnit
	dataType = TagConfigProps.DataType
	documentation = TagConfigProps.Documentation
	print Property.isInstance(TagProp)
	print Property.isInstance(TagConfigProps)
	# Start a non-recursive browse, and stores the configuration data in a variable
	for folderPath in folderPaths:
		tagConfig = system.tag.browseConfiguration(folderPath, False)
		# Iterate through the configuration data
		for tag in tagConfig:
		    #print "--------------------------------------------------------------------"
		    path = tag.getFullPath()
		    doc = tag.getOrDefault(documentation)
		    type = tag.getOrDefault(dataType)
		    unit = tag.getOrDefault(engUnit)
		    #print "Tag Path = '%s'" % (tag.getFullPath())
		    deadBand = tag.getOrDefault(db)
		    histSC = tag.getOrDefault(histSC)#histSC)
		    #print "Property '%s' has a value of '%s'" % (str(db), tag.getOrDefault(db))
		    hist = tag.getOrDefault(histEnabled)
		    #print "Property '%s' has a value of '%s'" % (str(histEnabled), tag.getOrDefault(histEnabled))
		    low = tag.getOrDefault(engLow)
		    #print "Property '%s' has a value of '%s'" % (str(engLow), tag.getOrDefault(engLow))
		    high = tag.getOrDefault(engHigh)
		    #print "Property '%s' has a value of '%s'" % (str(engHigh), tag.getOrDefault(engHigh))
		    if hist == True:
		    	propDict[path] = [doc,type,unit,hist,deadBand,histSC,low,high]
		    # Iterate through the list of propDict
		#print propDict.keys()
	    
	sortKeys = sorted(propDict)
	for key in sortKeys:
		#print key
		values = propDict.get(key)
		propList.append([key,values[0],values[1],values[2],values[3],values[4],values[5],values[6],values[7]])
	#for prop in propList:
	#	print prop
	ds = system.dataset.toDataSet(headers,propList)
	self.getComponent('Power Table').data = ds

```

The problem occurs on the line: histSC = tag.getOrDefault(histSC)#histSC)  
My best guess is this is a bug, but I want to see if I am doing something wrong in referencing this property.

Thanks.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 29, 2018, 9:12pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/9 "2018-03-29T21:12:11Z")

</div>

The property reference is fine, but after processing the first tag in the `tagConfig` you’re clobbering your `histSC` variable with something that isn’t a `Property` any more.

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [March 29, 2018, 10:43pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/10 "2018-03-29T22:43:59Z")

</div>

😅 oops… Thanks Kevin.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 27, 2023, 1:28pm UTC](https://forum.inductiveautomation.com/t/tag-get-propertyobject-not-working/17275/11 "2023-03-27T13:28:49Z")

</div>

> [@Kevin.Herron](#):
>
> com.inductiveautomation.ignition.common.tags.config.TagConfigProps

Hi @Kevin.Herron

If i try to use now  
from com.inductiveautomation.ignition.common.tags.config import TagConfigProps

error  
ImportError: cannot import name TagConfigProps

i am using ignition 8.1.17

I am trying get the history enabled or not using - **system.tag.browse**

can you help me how to get it
