You're currently browsing the Ignition 8.0 docs. Click here to view the latest docs.


With Perspective, individual component properties can have a property change script. When a change script is set up on a property, it will run when the property changes its value. Multiple different properties on the same component can each have different scripts configured. In Perspective, you can put a property change script on any component property. 

A very common example of a property change script would be to take the dataset from a binding and modify it into a new dataset using other information on screen. This can be accomplished with a Script Transform instead.

On this page ...


IULocgo


Property Change Scripts

Add a Property Change Script

  1. To add a property change script to a property, right click on the property Property Editor and select Add Change Script...



  2. The Edit Property Change Script screen is displayed. 




  3. Type in the script that you want to run and click OK


Property Change Arguments

ArgumentDescription
selfA reference to the component that has the property in question. If the property change script is on a session property, the session object will be passed.
previousvalueThe previous value, as a qualified value object. Qualified value objects have a value, quality, and timestamp.
currentValueThe new value, as a qualified value object. Qualified value objects have a value, quality, and timestamp.
origin

The origin of the property value, as a unicode string. The origin parameter will take on one of six types depending on how the property value is being updated:

NameDescriptionExample
BrowserUsed when the change comes from the Browser interface.The user changes the text property on a text field by typing a word into the field.
BindingUsed when the change comes from a binding (or transform) generating a new value.A Tag changes value, and a property with a binding to that tag is updated.
BindingWritebackUsed when the change comes from a bidirectional binding writing back to its source.ComponentB's value property has a bidirectional binding to the value property on ComponentA. If ComponentB's value changes, then a property change script on ComponentA will have an origin of BindingWriteback.
ScriptUsed when the change comes from a script.A user presses a button, and a script on the button assigns a new value to a custom property.
DelegateUsed when a change to a property comes from something intrinsic to the component's design.A complex component that automatically fills itself with data, like the alarm status table component.
SessionUsed when the session itself causes the property change.A change in user privileges causes access to be revoked, resulting in a change in the auth session property.
Project

Used when the default property value is changed in the designer and saved. 

A session property was set to a value of "A."  The default value of that property was then changed in the designer to "B" and saved. The value for that property changes from "A" to "B" in the running sessions.


Change Script Example

  1. Place a Text Field component and Label component on a Perspective View. 
  2. Select the Text Field component then right click on the text property. Click on Add Change Script.



  3. The Edit Property Change Script screen is displayed. Enter the following script, which will write the current value of the Text Field component to the Label component.

    self.getSibling("Label").props.text = currentValue.value







  4. Click OK to commit the script. You'll see that the Property Editor now shows a Change Script  icon next to the text property.

  5. Save your project.
  6. In a Perspective Session, enter some text into the Text Field component and hit Return. You'll see that the contents are repeated to the Label component. 





  • No labels