# Best approach to passing a parameter to an inherited view

**URL:** <https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [August 24, 2020, 6:30pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031 "2020-08-24T18:30:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott.stamps](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@scott.stamps](https://forum.inductiveautomation.com/u/scott.stamps)\
**Post date:** [August 24, 2020, 6:30pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031/1 "2020-08-24T18:30:59Z")

</div>

I have a “child” project which inherits a view from a “parent” project. For this view to function, it needs to know which tag provider to use; so we have defined a “tagProvider” parameter. The question is, what is the best way for a “child” project to pass along a parameter to an inherited view? Looking at the Page Configuration, something like “/base-page/:tagProvider” might work, but I’d actually like to be able to set the param value inline, e.g.: “/base-page/?tagProvider=my\_tag\_provider”, as this value will not change within the child project.

Appreciate any thoughts.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 24, 2020, 6:52pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031/2 "2020-08-24T18:52:41Z")

</div>

There’s some mixed terminology in use here because you’re asking about View parameters but using a Page Configuration.

- If you’re using any “Embedding” component, you want to specify the param value within the component.  
 ![Screen Shot 2020-08-24 at 11.51.39AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/05a63a624f1e3969ee2b200fbc5c302aa2db5dc0.png)
- If you’re navigating to a page via a URL, then you do want to use `/base-page/:my_tag_provider`.
- If this parameter is never going to change within a project, then you’re better off removing the parameter of the View altogether and instead binding to either the result of a database query (where the query obtains the provider based off of the project name), or a session property which contains the provider for the project.

---

<div class="post-metadata">

**Author:** ![scott.stamps](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@scott.stamps](https://forum.inductiveautomation.com/u/scott.stamps)\
**Post date:** [August 24, 2020, 7:05pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031/3 "2020-08-24T19:05:22Z")

</div>

It’s actually the 2nd bullet point - we’re navigating to the page. In your last bullet point, you mention using the project name and executing a query. Is project name the same as page.props.title? If so, this is what we’re currently doing, so maybe we’re not too far off.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 24, 2020, 9:47pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031/4 "2020-08-24T21:47:13Z")

</div>

> [@scott.stamps](#):
>
> Is project name the same as page.props.title?

No, `page.props.title` _defaults_ to the project name, but there's no guarantee that `page.props.title` will always have the name of the project as you could write anything you want to that property. If you decide to use a query, you'd want to have a Named Query in the parent project along the lines of

```auto
select tagProvider from providers where projectName="MyProjectName"

```

Then, in each child project you would override the Named Query and provide the name of the project. You're then on the hook for maintaining a database table with project-provider relations.

---

<div class="post-metadata">

**Author:** ![scott.stamps](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@scott.stamps](https://forum.inductiveautomation.com/u/scott.stamps)\
**Post date:** [August 25, 2020, 1:15pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031/5 "2020-08-25T13:15:46Z")

</div>

Got it. Just curious. Is there a property, similar to page.props.title, which exposes the current project name? I’ve seen system.util.getProjectName() but would prefer a prop, if it exists. Thanks.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 25, 2020, 3:43pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031/6 "2020-08-25T15:43:49Z")

</div>

There is not a session property, but the project name can be obtained through scripting. If you need the project name for something like this, I would set a custom property on session startup (in the Designer menu bar: Project \> Session Events \> Startup).

```auto
for ses in system.perspective.getSessionInfo():
    if ses.id == session.props.id:
        self.custom.projectName = ses.project

```

---

<div class="post-metadata">

**Author:** ![scott.stamps](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@scott.stamps](https://forum.inductiveautomation.com/u/scott.stamps)\
**Post date:** [August 25, 2020, 6:44pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031/7 "2020-08-25T18:44:44Z")

</div>

Interesting. I wasn’t aware of getSessionInfo().

While I realize this is going a bit beyond just the passing of parameters, can you provide thoughts on the following general approach for maintaining projects?

Database:

- Add a table - project, with columns (id, name, description, tag\_provider, etc…)

Base Project:

- Add a custom session property - projectId
- Using projectId, the Base Project could internally look up any needed project-specific info, such as tag\_provider, from the project table.

Child Project

- Add a custom session property - projectId (to override the base projectId property)

Usage would be to enter a row into the project table, then use that id to set the projectId property within the Child Project \> Base Project.

It seems like this would solve the original ask as well as offer a great deal of flexibility.

Appreciate your thoughts.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 25, 2020, 7:58pm UTC](https://forum.inductiveautomation.com/t/best-approach-to-passing-a-parameter-to-an-inherited-view/38031/8 "2020-08-25T19:58:12Z")

</div>

While I offered the DB solution, I advise against setting up a database just to maintain project information.

The proposed setup only gets you the capability to define a different Tag Provider for each project which you could easily do with just a custom session property within each project, without the added cost of maintaining your database. Your entire DB approach could be done with just having `session.custom.project_tag_provider` set within each project.
