OnChange

OnChange is used to execute Formulas with Python™ scripts or LiveCode scripts when a value for a sub-inspection test changes.

Also see Scripting in inspections

 

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. Depending on the test type, there may be variations on when the OnChange event is executed.

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 one of these occurs:

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

  • user selects a different SPC standard and clicks OK

Pass/Fail/NA

Yes

Rating

Yes

Timer

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

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

  • time remaining registers zero**

** If the time remaining 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).

Traceability (with EntryRestricted property set to False)

DMS Event, SPC Event, SPC Cause, and SPC Action Taken do not trigger OnChange.

Yes

Traceability (with EntryRestricted property set to True)

DMS Event, SPC Event, SPC Cause, and SPC Action Taken do not trigger OnChange.

Yes

*Lost focus:

When a user clicks or tabs to a test, that test has the focus until the user does one of these:

  • clicks on or tabs to another test (but not that test's individual note)

  • clicks the Submit button

  • clicks 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.

If the triggering event was clicking on another test that immediately triggers its own OnChange event - such as a Checkbox, Pass/Fail/NA, Rating, etc. - the OnChange script will first be launched for the "lost focus" event, and then it will be launched 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.)

OnChange events and the TestID property

The TestID property for sub-inspection tests is used by Python scripts in PC Collect to indicate which test in an inspection triggered an OnChange test formula.

When OnChange Formulas are executed in GS Collect

In GS Collect, Formula tests run LiveCode scripts.

The OnChange event executes when any of these conditions are met for a test:

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.