How to use custom method to get tag tree browser selected field value?

- script used in list component (custom method i have written this script)

In line 18 in my script i don’t know how to call tag tree browser selected tag path to the line

- getting this error

please help me out get solution

i tested by giving line 18 like this

my output is

- getting output like this

i am trying to drag and drop tags from tag tree browser to list component

if any correction in my script please let me know

The selected paths should come over as part of the Transferable.

line 19 in your code is looking for the paths variable to be a list of lists.

In your test if you did:

paths = [['test']]

you would see the result you were expecting.

However, you should be able to get the paths from the Transferable that comes with the event object e

like this

paths = [[path] for path in e.getTransferable().getTransferData(ListOfQualifiedPath.FLAVOR)]

This list comprehension constructs a list of lists from the selected paths. It is functionally equivalent to the following:

newList = []
for path in e.getTransferable().getTransferData(ListOfQualifiedPath.FLAVOR):

i am getting this error when i use this 3 lines this is the issue i am facing past one week . please give any alternative solution

my script (7.3 KB)

my project file can you check anything needs to be change?

Okay, so I had some free time today, and this will be a nice to have for my application so I dug in a little bit more.

Turns out that if you have the Tag Browse Tree mode configured as a Readtime Tag Tree then you get a different Transferable type.

If your mode is set to ‘Realtime Tag Tree’ then the transferable that is used is a ListOfNodeBrowseInfo
If your mode is set to ‘Historical Tag Tree’ the the transferable that is used is a ListOfQualifiedPath

I am sure there are reasons for that in the background.

That means your code needs to change slightly to use the correct Transferable Flavor

NOTE: If you have added the listener in the InternalFramActivated event you will need to close the window in the designer and re-open it once the change has been made.

from java.awt.dnd import DropTargetAdapter, DropTarget
from com.inductiveautomation.ignition.client.tags.dnd import ListOfNodeBrowseInfo
class customDragDropListener(DropTargetAdapter):
	_comp = None
	def __init__(self,comp):
		self._comp = comp
	def drop(self,e):
		paths = [[node.getFullPath()] for node in e.getTransferable().getTransferData(ListOfNodeBrowseInfo.FLAVOR) if not node.hasChildren() and node.getObjectType().toString() != 'Provider'] = system.dataset.addRows(,paths) if > 0 else system.dataset.toDataSet(['Selected Tags'],paths)
ddl = customDragDropListener(self)

Note that his will not accept a Folder or Provider, I didn’t take the time to handle that.

To properly handle these you will need to write a function which utilizes a recursive browse to gather the paths on a thread other than the GUI thread, should you want to handle a folder or provider in any way other than doing nothing. I have chosen to ‘ignore’ those items with this code.

1 Like

its working fine. thank you so much for your time. I have learned many things from you.

I would not call it a small change.

You’ll need to implement a recursive browse.

To do it properly you will need to use


If you look through the forum there are several examples and posts detailing the proper use of those functions.