# Template output parameters

**URL:** <https://forum.inductiveautomation.com/t/template-output-parameters/10601>\
**Category:** General Discussion\
**Created:** [October 9, 2015, 4:32pm UTC](https://forum.inductiveautomation.com/t/template-output-parameters/10601 "2015-10-09T16:32:01Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [October 9, 2015, 4:32pm UTC](https://forum.inductiveautomation.com/t/template-output-parameters/10601/1 "2015-10-09T16:32:01Z")

</div>

Thought I’d share a technique I’ve started using, enabled by [objectScript()](https://inductiveautomation.com/forum/viewtopic.php?f=50&t=14532) in v7.7, and possible with runScript() in v7.8. Specifically, how to create an “output” parameter in a template that instances can bind to? Publicly visible template parameters cannot be the destination of a binding inside the template. The solution so far is to create a template parameter and an internal property for each output, bind the appropriate tags/expressions to the internal property, and use the template’s ‘propertyChange()’ event to copy from the internal property to the template parameter.

With the help of objectScript() or the new runScript(), a more direct solution is possible: wrap the binding to the internal property in a function call that will also write to the template parameter. I use the following function in shared.util to handle gui thread property assignments:`def assignLater(comp, prop, val, ms = 0):
  import system
  def assignLaterInvoked(c=comp, p=prop, v=val):
    try:
      setattr(c, p, v)
    except:
      c.setPropertyValue(p, v)
  system.util.invokeLater(assignLaterInvoked, ms)
  return val`Note the return val at the end – it allows this function to work in a binding while also sending the value elsewhere. An example: given template parameters ‘tagfolder’ & ‘output’, this expression binding on an internal property will keep ‘output’ up to date:`objectScript("shared.util.assignLater(binding.target, 'output', args[0])",
  tag("[default]"+{myTemplate.tagfolder}+'/tagname'))`I haven’t tested the new runScript() features in Ignition v7.8 yet, but it would be something like this:`runScript("shared.util.assignLater(self, 'output', args[0])", 0,
  tag("[default]"+{myTemplate.tagfolder}+'/tagname'))`Two big advantages here: (1) the assignment code stays with the binding & (2) it runs all the time like any other binding.

The utility function could be simplified if you never need the delay – bindings always run on the gui thread (so far). Anyways, hope this helps someone.

---

<div class="post-metadata">

**Author:** ![robertm](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@robertm](https://forum.inductiveautomation.com/u/robertm)\
**Post date:** [April 2, 2024, 3:31pm UTC](https://forum.inductiveautomation.com/t/template-output-parameters/10601/2 "2024-04-02T15:31:41Z")

</div>

Old post, but is this still the method for 8.1.38?

This is Vision.

I have a template that is a bunch of data entry values (OPC tags) that change depending on a popup windows passed parameter. I drop this template into the popup window. From this same popup window I call another popup that needs to know whether all these values are zero or not (that's easy to determine...add them all \> 0).

Since the original properties of the values entered in the template aren't exposed to the first popup window, I started looking at creating an output parameter from the template which brought me to this answer.

My choices it seems are the above technique or, creating a custom property on the popup window and just bind an expression of all the OPC tags from the template added together. But since I try to keep multiple tags out of expressions, I've come here to determine the most efficient method.

---

<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:** [April 2, 2024, 4:29pm UTC](https://forum.inductiveautomation.com/t/template-output-parameters/10601/3 "2024-04-02T16:29:44Z")

</div>

Yes, still correct. Template parameters are functionally in/out. Vision Templates do not have dedicated output parameters.

(But nowadays, I never use the `tag()` function.)

---

<div class="post-metadata">

**Author:** ![robertm](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@robertm](https://forum.inductiveautomation.com/u/robertm)\
**Post date:** [April 2, 2024, 4:31pm UTC](https://forum.inductiveautomation.com/t/template-output-parameters/10601/4 "2024-04-02T16:31:55Z")

</div>

Yes, also trying to avoid tag() in any expressions.
