# Custom Menu using named query

**URL:** <https://forum.inductiveautomation.com/t/custom-menu-using-named-query/65771>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 27, 2022, 6:07pm UTC](https://forum.inductiveautomation.com/t/custom-menu-using-named-query/65771 "2022-10-27T18:07:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [October 27, 2022, 7:10pm UTC](https://forum.inductiveautomation.com/t/custom-menu-using-named-query/65771/4 "2022-10-27T19:10:41Z")

</div>

A query could be made to work, though I'm not sure you would be able to escape scripting completely.

Since this is really something that is global to the project I would consider a few options:

1. Use a project global variable to hold entire structure of menu. This could be generated by a query, or could even be a persitant object using `system.util.getGlobals()`. There is a very long discussion here about the pros/cons and how to's of that here:

> [@\[IGN-5244\]Persist Python Class Object](https://forum.inductiveautomation.com/t/ign-5244-persist-python-class-object/30498/3):
>
> That sounds risky. Would you say that writing a de-serialized method would be the preferred way to handle this in Ignition/Perspective? Would this be a good use case for Pickle? [https://docs.python.org/2/library/pickle.html](https://docs.python.org/2/library/pickle.html)

1. Create a script that could loop through the results of the query, or even a dictionary or JSON string, and parse it to the correct format. That script should reside in a project script. For instance perhaps create a session property that calls a function `getAuthorizedMenuTree()` and returns the valid tree structure based on what ever criteria is needed, for that users authorization level.

The easiest way to acquire the JSON for your menu structure is to build it out and copy it from the component. Otherwise you can use the structure from the menu example and change the values in the appropriate places.

Another option rather than storing this in a DB table would be to use a tag with a Document Type. That method would avoid the potential pitfalls of persisting a top level variable.

---

_[View the full topic](https://forum.inductiveautomation.com/t/custom-menu-using-named-query/65771)._
