# How to select a tag in the Tag Browse Tree through scripting

**URL:** <https://forum.inductiveautomation.com/t/how-to-select-a-tag-in-the-tag-browse-tree-through-scripting/62221>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [July 22, 2022, 3:08pm UTC](https://forum.inductiveautomation.com/t/how-to-select-a-tag-in-the-tag-browse-tree-through-scripting/62221 "2022-07-22T15:08:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [July 22, 2022, 3:08pm UTC](https://forum.inductiveautomation.com/t/how-to-select-a-tag-in-the-tag-browse-tree-through-scripting/62221/1 "2022-07-22T15:08:34Z")

</div>

As the title says, I have a view with a Tag Browse Tree component. On that view, I have a parameter called `tagPath` and I want to be able to pass in a path and it be selected in the Tag Browse Tree automatically… There is a `selection` property on the component, but it looks like it’s just read-only… When I paste a valid tag path in there, nothing happens (ie tag selection doesn’t change, folders don’t expand/collapse, etc).

Is there a way to do this? The desired behavior would be like the Table component’s row selection or column selection properties, where when you pass in a value, it’ll visibly select that row/column.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 22, 2022, 3:50pm UTC](https://forum.inductiveautomation.com/t/how-to-select-a-tag-in-the-tag-browse-tree-through-scripting/62221/3 "2022-07-22T15:50:16Z")

</div>

> [@YF129701](#):
>
> When I paste a valid tag path in there, nothing happens

Did you paste it directly on the `selection` property ?  
It doesn't work like that if the doc is to be trusted. The `selection` property should be an object, with 2 keys: `mode` and `values`. That last one is where you'd paste the selected value.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/118d1c260c9f8a3ba6e7600c8dec25eb4e94c802.png)

If that doesn't work, make sure you're using the format it expects. The easiest way to do that would be to select a tag in the tree in preview mode, see what the `selection` property looks like, and reproduce it.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [July 22, 2022, 3:56pm UTC](https://forum.inductiveautomation.com/t/how-to-select-a-tag-in-the-tag-browse-tree-through-scripting/62221/4 "2022-07-22T15:56:10Z")

</div>

That’s exactly what I tried, just selecting something in the tree and seeing the format it appears in. The tree is capable of multiselect so the `values` property is a list. In my case, the mode is set to `single` and I’m setting `values[0]` when the view loads. That part is working, it just doesn’t affect the TBT component in any way.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/1/610ca13b3cedf47b9024b6f4d7495b58f78614af.png)

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [July 22, 2022, 4:29pm UTC](https://forum.inductiveautomation.com/t/how-to-select-a-tag-in-the-tag-browse-tree-through-scripting/62221/5 "2022-07-22T16:29:38Z")

</div>

@pturmel made the introspect script that finds all available methods from a component. I ran it on the TagBrowseTree in Perspective but I don't see anything available that would let you select a path.

> [@Finding all available methods from a component](https://forum.inductiveautomation.com/t/finding-all-available-methods-from-a-component/9670/8):
>
> The introspection script has evolved over time, particularly to return a string result instead of just printing. I found that useful for introspection in gateway scope using runScript() in an expression tag. Or to set the .text property of a scrollable text edit field for convenience. This is what it looks like today: # Introspection for Jython/Java # # Copyright 2008-2016 Automation Professionals, LLC \<sales@automation-pros.com\> # # Redistribution and use in source and binary forms, with or…

```auto
Python Type: <type 'com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper'>
Java Type: <type 'com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper'>
  M: getSibling(<type 'java.lang.String'>)
    returns <type 'com.inductiveautomation.perspective.gateway.api.PerspectiveElement'>
  M: <type 'java.lang.String'> getName()
  M: getParent()
    returns <type 'com.inductiveautomation.perspective.gateway.api.Component'>
  M: <type 'void'> print(<type 'java.lang.String'>)
  M: <type 'java.util.Collection'> getChildren()
  M: getSession()
    returns <type 'com.inductiveautomation.perspective.gateway.api.Session'>
  M: getPage()
    returns <type 'com.inductiveautomation.perspective.gateway.api.Page'>
  M: getChild(<type 'java.lang.String'>)
    returns <type 'com.inductiveautomation.perspective.gateway.api.PerspectiveElement'>
  M: <type 'boolean'> refreshBinding(<type 'java.lang.String'>)
  M: getPropertyTreeOf(<type 'com.inductiveautomation.perspective.common.api.PropertyType'>)
    returns <type 'com.inductiveautomation.perspective.gateway.property.PropertyTree'>
  M: getView()
    returns <type 'com.inductiveautomation.perspective.gateway.api.View'>
  M: <type 'void'> requestTooltip()
  M: <type 'void'> focus()
  M: <type 'void'> removeTooltip()

From Type: <type 'java.lang.Object'>
  M: <type 'void'> wait(<type 'long'>)
  M: <type 'void'> wait(<type 'long'>,<type 'int'>)
  M: <type 'void'> wait()
  M: <type 'boolean'> equals(<type 'java.lang.Object'>)
  M: <type 'java.lang.String'> toString()
  M: <type 'int'> hashCode()
  M: <type 'java.lang.Class'> getClass()
  M: <type 'void'> notify()
  M: <type 'void'> notifyAll()

From python dir():
  Method __class__ <type 'java.lang.Class'>
  Method __copy__ <type 'builtin_function_or_method'>
  Method __deepcopy__ <type 'builtin_function_or_method'>
  Method __delattr__ <type 'builtin_function_or_method'>
  Property __doc__ <type 'str'> The most base type
  Method __ensure_finalizer__ <type 'builtin_function_or_method'>
  Method __eq__ <type 'builtin_function_or_method'>
  Method __format__ <type 'builtin_function_or_method'>
  Method __getattribute__ <type 'builtin_function_or_method'>
  Method __hash__ <type 'builtin_function_or_method'>
  Method __init__ <type 'instancemethod'>
  Method __ne__ <type 'builtin_function_or_method'>
  Method __new__ <type 'builtin_function_or_method'>
  Method __reduce__ <type 'builtin_function_or_method'>
  Method __reduce_ex__ <type 'builtin_function_or_method'>
  Method __repr__ <type 'builtin_function_or_method'>
  Method __setattr__ <type 'builtin_function_or_method'>
  Method __str__ <type 'builtin_function_or_method'>
  Method __subclasshook__ <type 'builtin_function_or_method'>
  Method __unicode__ <type 'builtin_function_or_method'>
  Property children <type 'java.util.Collections$EmptyList'> []
  Method class <type 'java.lang.Class'>
  Property name <type 'unicode'> TagBrowseTree
  Property page <type 'com.inductiveautomation.perspective.gateway.script.PageScriptWrapper$SafetyWrapper'> com.inductiveautomation.perspective.gateway.script.PageScriptWrapper$SafetyWrapper@6ae6c234
  Property parent <type 'com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper'> com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper@13e9d8ba
  Property session <type 'com.inductiveautomation.perspective.gateway.script.SessionScriptWrapper$SafetyWrapper'> com.inductiveautomation.perspective.gateway.script.SessionScriptWrapper$SafetyWrapper@137b9461
  Property view <type 'com.inductiveautomation.perspective.gateway.script.ViewModelScriptWrapper$SafetyWrapper'> com.inductiveautomation.perspective.gateway.script.ViewModelScriptWrapper$SafetyWrapper@1ba2a0a6
```

I think the component lets information flow one way only.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [July 22, 2022, 5:08pm UTC](https://forum.inductiveautomation.com/t/how-to-select-a-tag-in-the-tag-browse-tree-through-scripting/62221/6 "2022-07-22T17:08:39Z")

</div>

If that is the case, big sad. I feel like this should be a feature, I know this component is new (v8.1.16) so hopefully in the future, this functionality gets added.
