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.
In PC Collect, Formula tests run Python scripts.
The OnChange event is triggered when one of these occurs:
the sub-inspection is submitted. In this case, the OnChange formula is executed one last time before any Post formula (if one exists) is executed.
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: |
— |
Yes |
— |
|
Yes |
— |
— |
|
Yes |
— |
— |
|
— |
Yes |
— |
|
Yes |
— |
|
|
— |
Yes |
— |
|
— |
Yes |
— |
|
— |
— |
** 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 |
— |
When a user clicks or tabs to a test, that test has the focus until the user does one of these:
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.) |
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.
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: |
— |
Yes |
— |
|
Yes |
— |
— |
|
Yes |
— |
— |
|
Yes |
— |
— |
|
Yes |
— |
|
|
— |
Yes |
— |
|
— |
|
||
Yes |
— |
— |
|
*Lost focus: When a user taps a test, that test has the focus until the user taps one of these:
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. |