# Script tag path problem

**URL:** <https://forum.inductiveautomation.com/t/script-tag-path-problem/61859>\
**Category:** Ignition\
**Tags:** perspective, ignition80\
**Created:** [July 13, 2022, 4:02pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859 "2022-07-13T16:02:47Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [July 13, 2022, 4:02pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/1 "2022-07-13T16:02:47Z")

</div>

Hello, short question; i have a script which checks a tag folder, it works great on my testing folder but when i change the tag path to be my actual folder with more tags in it most of (but not all weirdly) the script stops working but it does not produce any errors so im confused as to why this is.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/2/026d801d49ab51797a69f402c2f0bfef3cafa047.png)  
by hashing out the first tagPath and unhashing the second one everything works good.  
My best guess is it doesnt like the spaces in my tag path(edit: spaces have nothing to do with this i put a space in my testing folder and it still works). Does anybody have any ideas?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [July 13, 2022, 4:06pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/2 "2022-07-13T16:06:38Z")

</div>

Perhaps try using recursion? See the bottom example from the docs, [system.tag.browse - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.tag.browse)

```auto
results = system.tag.browse("[default]", {"tagType":"UdtInstance", "recursive":True}).results
for result in results:
        print str(result['fullPath'])

```

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [July 13, 2022, 4:21pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/3 "2022-07-13T16:21:11Z")

</div>

Well this didnt cause any errors but its just reading from the entire [default] and not the specific folder i want

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/b/5b182b7700154bbafe36ce82164b5941c5297565.png)

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [July 13, 2022, 4:54pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/4 "2022-07-13T16:54:39Z")

</div>

Sorry, I just copied their example as-is, you will need to edit for your use, something like,

```auto
tagPath = "[default]DTL_Ramp/Ramp PLC Connection Tags/Ramp1/Event"
results = system.tag.browse(tagPath, {"tagType":"AtomicTag", "recursive":True}).results
for result in results:
        print str(result['fullPath'])

```

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [July 13, 2022, 4:55pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/5 "2022-07-13T16:55:05Z")

</div>

It actually works with any folder path except the one i need it to work with… am i going insane it makes no sense

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [July 13, 2022, 4:57pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/6 "2022-07-13T16:57:48Z")

</div>

Thank you for the response but this also did not work, its still returning values from the whole [default] for some reason, regardless i dont think recursion is the problem because it works with other folders without needing to do that

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [July 13, 2022, 4:59pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/7 "2022-07-13T16:59:24Z")

</div>

If you copy and paste the script I did into the script console and hit execute, what do you get?

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [July 13, 2022, 5:03pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/8 "2022-07-13T17:03:11Z")

</div>

> [@jlandwerlen](#):
>
> ```auto
> tagPath = "[default]DTL_Ramp/Ramp PLC Connection Tags/Ramp1/Event"
> results = system.tag.browse(tagPath, {"tagType":"AtomicTag", "recursive":True}).results
> for result in results:
> print str(result['fullPath'])
> 
> ```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/0/7040a0f6d2e324b75ca25586af0d085d2f648ed9.png)  
Nothing actually

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 13, 2022, 5:08pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/9 "2022-07-13T17:08:21Z")

</div>

remove the filter for `AtomicTag` and see if it returns something then?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [July 13, 2022, 5:08pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/10 "2022-07-13T17:08:23Z")

</div>

No idea, short of you have the wrong path or on a version with bugs. Maybe try different variations, but I don’t know what is going on. I can’t say that I have ever had a problem like you describe.

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [July 13, 2022, 5:19pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/11 "2022-07-13T17:19:16Z")

</div>

This is actually based off your code from another post (you used tooltip as a holding place to put in previous value which was genius by the way) do you happen to know if maybe the script breaks if there are too many tags in the folder or something? it actually is looking in the right folder all along because if i change the OPC server name of some tags to something else the script will return them, again very weird.

```auto
import system
import numbers
import datetime
import system
import sys

def grouper(n, iterable): #ignition bug need to import and all that in the function you are using below
    return zip(*[iter(iterable)] * n)
    
def logDB_new(tags):
    tagReadList = []
    import system
    def grouper(n, iterable):
        return zip(*[iter(iterable)] * n)

    for tag in tags:
        tagReadList.append(str(tag['fullPath']))
        tagReadList.append(str(tag['fullPath']) + '.Tooltip')

    qValues = system.tag.readBlocking(tagReadList)

    writeList = []
    writeValues = []

    query = "INSERT INTO tL_EventNew (Name,TagValue,t_stamp) VALUES " 
    queryVals = []

    for currentValues, prevValues in grouper(2,zip(tagReadList, qValues)):
        name, curQValue = currentValues  
        prevName, prevQValue = prevValues 

        prevValueString = prevQValue.value    
        curValue = curQValue.value
        t_stamp = curQValue.timestamp
        writeList.append(prevName)
        writeValues.append(curQValue.value)
        if prevValueString == 'false':
        	prevValue = False
        else:
        	prevValue = True

        if (curValue != prevValue):
        
			
			KepTagName = name.replace("/",".")
			#KepTagName = KepTagName.replace("[default]TestingTags","OMRON_FINS.Ramp1_PLC.Event")
			KepTagName = KepTagName.replace("[default]DTL_Ramps.Ramp PLC Connection Tags.Ramp1","OMRON_FINS.Ramp1_PLC.Event") 
			param = {"KepTagName":KepTagName}
			
			queryVals += [KepTagName,curValue,system.date.now()]
			print KepTagName, curValue, prevValue
			
			EventID =-1
			data = system.dataset.toPyDataSet(system.db.runNamedQuery("EventsLog/ScriptNameExtraction", param))
			if data:
				EventID = data[0][0]
			print "EventID = " + str(EventID)

			state = bool(curValue)
			print "state = " + str(state)
			
			param2 = {"TagName":KepTagName, "curValue":state}
			system.db.runNamedQuery("EventsLog/UpdateTPEvents", param2)
			

			if curValue == 1:
				OperatorPath = ["[default]DTL_Ramps/LoggedInOp/Ramp1"]
				OpID = system.tag.readBlocking(["[default]DTL_Ramps/LoggedInOp/Ramp1"])[0]
				print "Op ID = " + str(OpID.value)
				param3 = {"EventID":EventID, "State":state, "OpID":OpID.value}
				if EventID > -1:
					print "running insert"
					system.db.runNamedQuery("EventsLog/UpdateTLEvents", param3)
			else:
				param5 = {"EventID":EventID}
				system.db.runNamedQuery("EventsLog/DatetimeReset", param5)
				 
    query += ','.join(['(?,?,?)'] * (len(queryVals) / 3))
    system.tag.writeBlocking(writeList,writeValues)

    if queryVals:
        print "writing to database"
        system.db.runSFPrepUpdate(query,queryVals,datasources=['Ignition_Dean'])

tagPath = "[default]DTL_Ramps/Ramp PLC Connection Tags/Ramp1/Event"
#tagPath = "[default]DTL_Ramps/Ramp PLC Connection Tags/Ramp1/Operators"
#tagPath2 = "[default]DTL_Ramps/Ramp PLC Connection Tags/Ramp1/Event"
#tagPath = "[default]Testing Tags/New Folder"
#tagPath = system.tag.browse(tagPath2, {"tagType":"UdtInstance", "recursive":True}).results
#tagPath = "[default]Testing Tags"
tags = system.tag.browse(tagPath,{'tagType' : 'AtomicTag'}).getResults()
logDB_new(tags)

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 13, 2022, 5:32pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/12 "2022-07-13T17:32:00Z")

</div>

> [@Dean\_Walsh](#):
>
> (you used tooltip as a holding place to put in previous value which was genius by the way)

I would love to take credit for that, but it wasn't my Idea it was something the original poster was already doing.

There shouldn't be any limit on the tags. The only thing that should be limiting the number of results returned is the filter.

If you change the browse operation code to this: Do you get results printed out?

```auto
tags = system.tag.browse(tagPath).getResults()
print tags

```

Perhaps @JordanCClark sees/knows something I don't?

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [July 13, 2022, 6:26pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/13 "2022-07-13T18:26:13Z")

</div>

Stupid question, but I didn’t see it asked above so I have to ask it: if you right click on the folder you are trying to browse tags from in the Tag Browser, and select “Copy Path” is it exactly the same as the path you included in your system.tag.browse() call? I can’t tell you how many times I have accidentally messed up something simple like this with a minor typo. 🙂

Edit: Your original post shows:

```auto
tagPath = "[default]DTL_Ramp/Ramp PLC Connection Tags/Ramp1/Event"

```

And your last follow up post lists the first folder name as plural:

```auto
tagPath = "[default]DTL_Ramps/Ramp PLC Connection Tags/Ramp1/Event"

```

If I was a gambling man, that’d be what I place my money on as the culprit, but let us know either way!

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [July 14, 2022, 8:22am UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/14 "2022-07-14T08:22:34Z")

</div>

Yes unfortunately this is not the problem, ive been using copy path the whole time but thanks for the response

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [July 14, 2022, 8:57am UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/15 "2022-07-14T08:57:50Z")

</div>

I know this seems unlikely but im fairly sure my events folder is haunted by satan himself, i made another folder exactly the same called Events2 beside Event with a copy of all the tags in it and it works???

im just using the second folder and calling it a day, im no match for satan, if this causes problems later for me oh well

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [March 31, 2023, 5:51pm UTC](https://forum.inductiveautomation.com/t/script-tag-path-problem/61859/16 "2023-03-31T17:51:21Z")

</div>

Dean, hoping you see my question here:  
what does your code do exactly? Are you storing a list of tags in a DB table and their values?

Curious that I might want to try this myself if it would be useful.

Thanks
