OnChange

A Formula test with the FormulaMode property set to OnChange executes a Python script or LiveCode script when a value for a sub-inspection test changes.

 

Contents  [Hide]

 

OnChange is intended to execute a script after an inspector modifies a sub-inspection. It only executes a script for a test when certain conditions are met for that test.

Note: If a sub-inspection contains two Formula tests, one with the FormulaMode property set to Pre, and the other set to OnChange, the script set to Pre always executes first.

When OnChange Formulas are executed in PC Collect

In PC Collect, Formula tests run Python scripts.

The OnChange event is triggered when any of these conditions are met:

Condition:

Details:

Sub-inspection is submitted

The OnChange formula is executed one last time before any Post formula (if one exists) is executed.

Checkbox test value changes

n/a

DMS Standard test value changes

n/a

Pass/Fail/NA test value changes

n/a

Rating test value changes

n/a

Traceability test (with EntryRestricted property set to True) value changes

Traceability tests for DMS Event, SPC Event, SPC Cause, and SPC Action Taken do not trigger OnChange events.

Timer test starts, stops, or counts down to zero

One of the following occurs:

  • The user clicks Start (or presses the Spacebar to start).

  • The user clicks Stop (or presses the Spacebar to stop).

  • The Remaining Time registers zero.
    If the Remaining Time registers zero while another script is already running, the OnChange formula will be triggered for this event after the current script has executed (unless the sub-inspection was submitted or canceled before the timer registered zero).

Numeric Input test changes SPC standard

The user selects a different SPC standard and then clicks OK.

Numeric Input test value changes

After changing the value of the test, the OnChange event will be triggered when one of the following occurs:

  • The user clicks the Submit button.

  • The user clicks the Cancel button.

  • With the focus on the last cell of the Numeric Input test, last cell of the OEE test, or last Defect of the Defect List test, the user tabs out of the current test by pressing the TAB key (or by pressing the ENTER key if the inspection's EnterKeyBehavior property is set to Tab).

  • The user clicks on another test that can accept the focus because the user can change its value. (This does not include clicking on any test's individual note.)
    If clicking another test such as Checkbox, Pass/Fail/NA, Rating, etc. changes that test's value and triggers a new OnChange event, the OnChange script will first be executed for the "lost focus" event, and then it will be executed a second time for the "click" event. In this scenario, the first OnChange script is not aware that the second test's value has changed - it is only aware of the change in the test that lost focus. (The second OnChange script is then aware of the change in the test that was clicked on.)

OEE test value changes

Defect List test value changes

Date/Time test value changes

After changing the value of the test, the OnChange event will be triggered when one of the following occurs:

  • The user clicks the Submit button.

  • The user clicks the Cancel button.

  • The user tabs out of the current test by pressing the TAB key (or by pressing the ENTER key if the inspection's EnterKeyBehavior property is set to Tab).

  • The user clicks on another test that can accept the focus because the user can change its value. (This does not include clicking on any test's individual note.)
    If clicking another test such as Checkbox, Pass/Fail/NA, Rating, etc. changes that test's value and triggers a new OnChange event, the OnChange script will first be executed for the "lost focus" event, and then it will be executed a second time for the "click" event. In this scenario, the first OnChange script is not aware that the second test's value has changed - it is only aware of the change in the test that lost focus. (The second OnChange script is then aware of the change in the test that was clicked on.)

Traceability tests for DMS Event, SPC Event, SPC Cause, and SPC Action Taken do not trigger OnChange events.

Traceability test (with EntryRestricted property set to False) value changes

OnChange events and the TestID property

Each time an OnChange event is triggered, your Python script can check the testid variable to discover which TestID triggered the OnChange event. For more information, see About the TestID property.

When OnChange Formulas are executed in GS Collect

In GS Collect, Formula tests run LiveCode scripts.

The OnChange event is triggered when any of these conditions are met:

Test

When the focus on this test is lost and the value for it changes:*

When the value for it changes (but it has the focus):*

When any of these specific conditions are met:

Checkbox

Yes

Date/Time

Yes

Defect List

Yes

DMS Standard

Yes

Numeric Input

Yes

  • an SPC standard is selected

Pass/Fail/NA

Yes

Timer

  • timer starts

  • timer stops

  • time remaining registers zero

Traceability

Yes

*Lost focus:

When a user taps a test, that test has the focus until the user taps one of these:

  • another test

  • the Submit button

  • the Cancel button

At that moment, the focus on that test has been "lost" – and if the value for that test has changed, the OnChange formula is triggered.

 

More information