Click navigation element?

  • 1
  • Question
  • Updated 1 year ago
  • In Progress
We are standardizing on the Navigation component to do actions on our pages.  For buttons or even table row actions, I have written snippets that simulate a click of a specific button or row action - simply using this line:
document.getElementById("myButton").click();

Is there a way I can simulate this on a navigation component?

Here's my use case, and I feel there are several ways to skin this cat:

We have a Nav item labeled "Respond" and conditional rendering to show this nav item under certain record status, who the running user is, yadda yadda.

Sometimes I want the label to be something else, like "Change Response".

So my thought was that I would create another nav sub item labeled Change Response, apply my conditional rendering, and then just write a snippet to click the original Respond nav item because I don't want to create all the logic that is on Respond again - they need to stay identical, and I don't want to have to maintain both.

So, options I see:
Option 1: Dynamically change the label of my Nav sub item using a snippet
Option 2: Create 2nd duplicate Change Response nav item that clicks the original Respond via a snippet
Option 3: Create both Nav items and have duplicated actions.  (booooo)

Photo of Chandra V

Chandra V, Champion

  • 6,966 Points 5k badge 2x thumb

Posted 1 year ago

  • 1
Photo of John Dahlberg

John Dahlberg, Champion

  • 2,474 Points 2k badge 2x thumb
You can use merge syntax to drive the display of navigation items.  You might try setting up a UI or even a data driven model based on the criteria you're looking for and reference that model's field in the Nav.  Here's an example using a global parameter to display the currently logged in user in a Navigation component:

This goes in the Label:  MySite ({{$User.firstName}})

Unfortunately, the Navigation component isn't dynamic in terms of dynamically creating structure based on a data source like you can do with queues and other model-centric components, so aside from getting creative with driving the display, you're left with using rendering to toggle an item on and off.