Example–Using Events with the Data Standard Dialog

Invoke events when a value changes in the Data Standard dialog. These events can be used to call scripts.

How to Use an Event

It is important to understand the code segments that are embedded in Data Standard.

Events can be added to a property so that every time the event happens, a script function executes. Following are some example lines:

$Prop["Company"].add_PropertyChanged({
param(-$parameter,-$source)
if($source.propertyname--eq-"value") {
Company_OnPropertyChanged }
})

A property must be selected to add the event. In the code above, the function .add_PropertyChanged() adds the event, but the function requires one parameter. This parameter begins with a brace {. The parameters that the script function needs mut be declared.

The second part of the code is the function named Company_OnPropertyChanged. Company is the PropertyName. In the following lines of code, the function makes a control named ADVANCED visible if something is entered in the Company field, or collapses the control if the field is empty.

function Company_OnPropertyChanged
{
  if($Prop["Company"].Value -eq "")
  {
    $dsWindow.findName("advanced").Visibility = "visible"
  }
  else
  {
    $dsWindow.findName("advanced").Visibility = "collapsed"
  }
}

Property triggers are best defined in the InitializeWindow function.