# Trigger Navigation in Designer

**URL:** <https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927>\
**Category:** Module Development\
**Tags:** perspective\
**Created:** [May 4, 2024, 11:24pm UTC](https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927 "2024-05-04T23:24:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [May 4, 2024, 11:24pm UTC](https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927/1 "2024-05-04T23:24:30Z")

</div>

Is there a way to automatically trigger navigation to a resource within the Designer Context?

Ideally something similar to when you Find/Replace and you select a found item and it navigates directly to the view.

Specifically, I want to be able to trigger opening a Perspective resource from within a module. However if it was a generic resource opening function, that would be nice too.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 6, 2024, 4:50pm UTC](https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927/2 "2024-05-06T16:50:22Z")

</div>

If you're on a new enough SDK (8.1.34/whenever the tag reference tracker was introduced), you can use the `Location`/`Locatable` classes as your entrypoint.

Construct a `com.inductiveautomation.ignition.designer.location.Location`, then pass it to the module you want to locate (use `Locatable.forward` to allow passing any random module ID):

```java
        String perspectiveModuleId = "com.inductiveautomation.perspective";
        DesignerModuleHook perspective = context.getModule(perspectiveModuleId);
        ResourceType resourceType = new ResourceType(perspectiveModuleId, "views");
        ProjectResourceId resourceId = new ProjectResourceId(context.getProjectName(), resourceType, "path/to/view");
        Locatable.forward(perspective, new Location(resourceId, Map.of()));

```

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [May 6, 2024, 5:29pm UTC](https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927/3 "2024-05-06T17:29:08Z")

</div>

Okay, this makes sense for something clearly defined in a module like that,

Is it possible for items that are included in the core installation as well? Like project scripts?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 6, 2024, 6:04pm UTC](https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927/4 "2024-05-06T18:04:55Z")

</div>

> [@kgamble](#):
>
> Like project scripts?

This hasn't been implemented for project scripts in particular, because there's no way for TRT to drill into a project script - it only captures the call, not the library depth.

You want to get a `ScriptWorkspace` so you can call `openScript`: [ScriptWorkspace](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.40-rc1/com/inductiveautomation/ignition/designer/scripteditor/workspace/ScriptWorkspace.html#openScript(com.inductiveautomation.ignition.common.project.resource.ResourcePath))

But I'm not sure if there's any good way to do that...

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 6, 2024, 6:07pm UTC](https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927/5 "2024-05-06T18:07:45Z")

</div>

Debatably "good" (at least doesn't rely on reflection):

```java
MutableNavTreeNode scriptFolder = context.getProjectBrowserRoot().getScriptFolder();
for (int i = 0; i < scriptFolder.getChildCount(); i++) {
    var child = scriptFolder.getChildAt(i);
    if (child instanceof ScriptPackageNode scriptFolder) {
        scriptFolder.workspace.openScript(someScriptResourcePath);
    }
}

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 6, 2024, 6:20pm UTC](https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927/6 "2024-05-06T18:20:10Z")

</div>

> [@paul-griffith](#):
>
> it only captures the call, not the library depth.

The library depth is noted in the jython frame code's `co_filename` and the current line number is in the jython frame itself. So the TRT should be able to capture that level of detail.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 6, 2024, 6:25pm UTC](https://forum.inductiveautomation.com/t/trigger-navigation-in-designer/89927/7 "2024-05-06T18:25:15Z")

</div>

You're right - 'no way' was incorrect, and I argued the point at the time, but the decision was made to favor performance. May or may not get revisited at some point.
