How to Reuse Parameters and Custom Properties

Hi Forum,

I have multiple views that use the same parameters and custom properties expressions/scripts, like so:
image

How do I reuse this, such that if I have multiple views, that use exactly the same,
I do not have to rewrite them?

Use session.custom instead.

Oh That....
hmmm... I was there.

On the early phase of this tool, I decided to make this feature to be localized on the page level. So that when user needs to investigate, they can open multiple tab in browser use this tool independently.

I don't know, probably I could use an empty view with two parameter objects named input and output.. Embed and Hide this on the view it going to be used.

Looks awkward.. I wonder if it would run..

page.props.pageId appears to be unique in each browser tab or window. It returns an 8-character hex code.

You could try creating a session.custom.pages dictionary of the form,

{
  "P123cc4f3": {
    "xPlusY": 5,
    "xTimeY": 6
  },
  "Pa9472c": {
    "xPlusY": 7,
    "xTimeY": 3
  }
}

Every time the page is loaded add a dictionary element made of the page.props.pageId. I've added a leading 'P' in case there's a problem with an object key starting with a number. (I suspect that Ignition 8.1 will take it but you'll have a red warning on the session.custom props.)

I haven't thought this through but I think it should all disappear when the last page for that application is closed.

So what you're asking is, how to make some set of variables common to multiple views ?
That depends on the scope. Should it be session wide, page wide, gateway wide... ?

It's, "How to make some set of variables common to multiple views within the one browser tab / window." (Simple session variable bindings would affect all open tabs / windows for the same Ignition application.)

Hope below illustration explains what I am trying to do:



Basicly, I have a set of input params, (e.g. a parent tagPath) and set of custom properties ( driven by the input params) on one view (tile template)

Instead of a tile I wanted to make table format this time.
I created another view (same input params, same custom properties)

Oh, I wanted to show it into Carousel View.
Re-iterate same input params, same custom properties)

Oh, I need to change the formula of binding. Now I went to edit the 3 views, now is a mess.

I'd like to think of it as an SFC block, that I can use on views.
I actually did it, using an empty view as my original. And embed this view to other view.

I ended up, wiring input params to embed views input, using multiple "On change script" on embed views output to write data to the current views Custom Properties. idk if this is efficient.

This problem (page-wide persistence, but not session-wide) was part of the motivation for the pageVarMap() function in my Integration Toolkit.

The catch is that writes to content must be scripted. But all views in a page that bind to pageVarMap() will get the same dictionary (aka mapping object).

What I did:


Finally, you showed up.. Finally would be able to investigate what pageVarMap really do.. I was lost on reading, what it is trying to do last time.