Use Events with the Data Standard Dialog

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

Understand 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:

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 "{". 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 the groupbox visible if something is entered in the Company field. The groupbox collapses if that field is left empty.

function Company_OnPropertyChanged
{
    if($parameter.Value -ne $null -and $parameter.Value.Length -gt 0)

    {   

          $dsWindow.findName("ADVANCED").Visibility = "visible"

    }

    else

    {

         $dsWindow.findName("ADVANCED").Visibility = "collapsed"

    }

}

The $parameter contains the property value and based on that information, the code can call the content of it or determine other information. The if-then statement calls the "$dsWindow.findName("ADVANCED").Visibility" function, where if the parameter is not empty, the groupbox becomes visible. If the parameter is empty, the groupbox is collapsed. The $dsWindow.findName function can be used to find any field in the xaml that has a name.

Once you know the syntax for your event trigger, you can set it up to intialize whenever the Data Standard window opens:

function InitializeWindow

{

$dsWindow.Width = 600

$dsWindow.Height = 480

#$dsDiag.Inspect();

$Prop["Company"].add_PropertyChanged({

                param( $parameter)

              #$dsDiag.Inspect();

              Company_OnPropertyChanged

  })

}
Tip: This type of event trigger works for any .xaml control that has visibility properties. You can also do the same sort of trigger with the IsEnabled property. The only difference is you have to set it to true or false. You can even swap rows and columns to create a more dynamic layout for your dialog.