Skip to content

Input Test

The Input Test is used in Inspections to gather custom input from the user. It does not store its contents when the Sub-Inspection is submitted, but is only used within Inspection Scripts. The Input Test can be used either as a free-form input or a dropdown list.

Input Test

Settings

Setting Description
Label The display name shown to the operator during the Inspection.
Visible Whether the Test is shown to the operator in the Inspection. A Test's visibility does not affect validation.
Enabled Whether the Test can accept user input. Disabling a Test can be useful when the value is set via scripting.
Script ID Identifies how this Test is referenced in Inspection Scripts.
Required Whether the operator must complete this Test before submitting the Sub-Inspection.
Value The preset value of the Test when the Sub-Inspection loads.
Border Whether to display a visual border around the Test in the Inspection layout.
Freeze Test If this Test is placed on the same row as a taller Test, this Test will not scroll off the screen until the taller Test scrolls off the screen.
Multiline Whether the Test should accept multiple lines of text in the input.

Using the InputTestApi

The Input Test is usually used within an Inspection Script by reading its value as a string.

const inputTest = gsApi.inspection.subInspection('measurements').input('my input');

inputTest.onFocusOut(async (e) => {
    if (e.data.hasChanged) {
        const inputProps = await inputTest.getProperties();
        console.log('The new value is', inputProps.value);
    }
});

The Input Test can be changed to a dropdown list by setting its options property to an array of ID-Name objects. When an option is selected, the value of the Test will become the selected option's ID.

const subi = gsApi.inspection.subInspection('measurements');
const inputTest = subi.input('my input');

subi.onAfterStart(async () => {
    // Set up the options in the test, turning it into a dropdown
    await inputTest.updateProperties({
        options: [
            { id: 1, name: 'Option 1' },
            { id: 65, name: 'Option 65' },
            { id: 2, name: 'Option 2' },
        ]
    });
});

inputTest.onOptionSelected(async (e) => {
    // Get the selected option's ID
    const inputProps = await inputTest.getProperties();
    console.log('The selected ID is', inputProps.value);
});

See Also