Skip to content

Scripting API / inspection/InspectionApi

inspection/InspectionApi

Modules

Module Description
External -

Classes

InspectionApi

Methods

addSubInspection()

addSubInspection(subInspectionProperties, index?): Promise<void>

Adds a new sub-inspection with given values.

Parameters
Parameter Type Description
subInspectionProperties SubInspectionWorkerCreate Object with properties for the new sub-inspection.
index? number Index to insert the new sub-inspection in the list of sub-inspections.
Returns

Promise<void>

allSubInspectionEvents()

allSubInspectionEvents(): AllSubInspectionEventsApi

Allows event binding to all sub-inspections.

Returns

AllSubInspectionEventsApi

An object which allows access to sub-inspection event bindings.

cancelCurrentSubInspection()

cancelCurrentSubInspection(): Promise<void>

Cancels the current sub-inspection. If no sub-inspection is showing, does not do anything.

Returns

Promise<void>

completeInspection()

completeInspection(): Promise<void>

Cancels the currently running Sub-Inspection and marks the Inspection and all Sub-Inspections as complete. If there was a currently running Sub-Inspection, the onBeforeEnd event will be triggered.

If the Inspection is already complete, this function will have no effect.

Calling this function will not trigger the onComplete event.

Returns

Promise<void>

getCurrentPart()

getCurrentPart(): Promise<GSBaseEntity | null>

The current Part that will be recorded for data records.

This uses the following order of precedence: 1. The value of a Part test on the current sub-inspection 2. The value of a Part test in the global tag area 3. The value of the Part set on the Inspection 4. Null

Note that some tests can override this Part on a per-test basis.

Returns

Promise<GSBaseEntity | null>

getCurrentProcess()

getCurrentProcess(): Promise<GSBaseEntity | null>

The current Process that will be recorded for data records.

This uses the following order of precedence: 1. The value of a Process test on the current sub-inspection 2. The value of a Process test in the global tag area 3. The value of the Process set on the Inspection 4. Null

Note that some tests can override this Process on a per-test basis.

Returns

Promise<GSBaseEntity | null>

getCurrentSubInspectionScriptId()

getCurrentSubInspectionScriptId(): Promise<string | null>

Retrieves the id of the current sub-inspection. If no sub-inspection is active, then this will return null.

Returns

Promise<string | null>

getProperties()

getProperties(): Promise<InspectionWorkerGet>

Retrieves the properties from the inspection.

Returns

Promise<InspectionWorkerGet>

globalTagArea()

globalTagArea(): GlobalTagAreaApi

Allows modification, retrieval, and event binding of tests inside the global tag area.

Returns

GlobalTagAreaApi

goToInspection()

goToInspection(id): Promise<void>

Navigates to a specific inspection, by internal ID.

If called during the onBeforeEnd event, any pending submissions will be cancelled.

Calling this function will not trigger onBeforeEnd or onAfterEnd of the current sub-inspection.

When called by a User with inspectionListRunAnyRevision permission, the latest revision will be loaded. Otherwise, the published revision will be loaded.

If the user does not have the inspectionListRunAnyRevision permission and there is no published revision, or the user is assigned to the Inspection, an error will be thrown. When this error is thrown, this script will have been destroyed. This error may not be caught.

Parameters
Parameter Type Description
id number The internal id of the inspection.
Returns

Promise<void>

goToInspectionList()

goToInspectionList(): Promise<void>

Navigates to the list of inspections.

If called during the onBeforeEnd event, any pending submissions will be cancelled.

Calling this function will not trigger onBeforeEnd or onAfterEnd of the current sub-inspection.

Returns

Promise<void>

goToMySchedules()

goToMySchedules(): Promise<void>

Navigates to the mySchedules page. If the user does not have permissions to view schedules, this call will be ignored.

If called during the onBeforeEnd event, any pending submissions will be cancelled.

Calling this function will not trigger onBeforeEnd or onAfterEnd of the current sub-inspection.

Returns

Promise<void>

goToSubInspection()
Call Signature

goToSubInspection(scriptId): Promise<void>

Navigates to the given sub-inspection.

If called during the onBeforeEnd event, any pending submissions will be cancelled.

Calling this function will not trigger onBeforeEnd or onAfterEnd of the current sub-inspection.

Parameters
Parameter Type Description
scriptId string Unique id of the sub-inspection.
Returns

Promise<void>

Call Signature

goToSubInspection(scriptId): Promise<void>

Navigates to the given sub-inspection.

If called during the onBeforeEnd event, any pending submissions will be cancelled.

Calling this function will not trigger onBeforeEnd or onAfterEnd of the current sub-inspection.

Parameters
Parameter Type Description
scriptId string Unique id of the sub-inspection.
Returns

Promise<void>

goToSubInspectionList()

goToSubInspectionList(): Promise<void>

Navigates to the list of sub-inspections.

If called during the onBeforeEnd event, any pending submissions will be cancelled.

Calling this function will not trigger onBeforeEnd or onAfterEnd of the current sub-inspection.

Returns

Promise<void>

onComplete()

onComplete(fn): ScriptEventSubscription

Bind a function to fire when all subinspections have been completed. This is checked on subinspection completion, and will never fire if there are no sub inspections.

Parameters
Parameter Type Description
fn (event) => void The function to fire.
Returns

ScriptEventSubscription

ScriptEventSubscription

onDateTimeChanged()

onDateTimeChanged(fn): ScriptEventSubscription

Bind a function to fire when the inspection date/time has changed

Parameters
Parameter Type Description
fn (event) => void The function to fire.
Returns

ScriptEventSubscription

ScriptEventSubscription

onPartChanged()

onPartChanged(fn): ScriptEventSubscription

Bind a function to fire when the inspection process has changed

Parameters
Parameter Type Description
fn (event) => void The function to fire.
Returns

ScriptEventSubscription

ScriptEventSubscription

onProcessChanged()

onProcessChanged(fn): ScriptEventSubscription

Bind a function to fire when the inspection process has changed

Parameters
Parameter Type Description
fn (event) => void The function to fire.
Returns

ScriptEventSubscription

ScriptEventSubscription

onReady()

onReady(fn): ScriptEventSubscription

Bind a function to fire when the inspection is ready.

Parameters
Parameter Type Description
fn (event) => void The function to fire.
Returns

ScriptEventSubscription

ScriptEventSubscription

onTraceabilityChanged()

onTraceabilityChanged(fn): ScriptEventSubscription

Bind a function to fire when a traceability value for the inspection has changed

Parameters
Parameter Type Description
fn (event) => void The function to fire.
Returns

ScriptEventSubscription

ScriptEventSubscription

removeSubInspection()
Call Signature

removeSubInspection(scriptId): Promise<void>

Removes a sub-inspection from the inspection.

Parameters
Parameter Type Description
scriptId string Unique id of the sub-inspection to remove
Returns

Promise<void>

Call Signature

removeSubInspection(scriptId): Promise<void>

Removes a sub-inspection from the inspection.

Parameters
Parameter Type Description
scriptId string Unique id of the sub-inspection to remove
Returns

Promise<void>

subInspection()
Call Signature

subInspection<T>(scriptId): SubInspectionApi<T>

Allows modification, retrieval, and event binding of a sub-inspection with the given id.

Type Parameters
Type Parameter
T extends string
Parameters
Parameter Type Description
scriptId T Unique id of the sub-inspection.
Returns

SubInspectionApi<T>

An object which allows access to the sub-inspection methods

Call Signature

subInspection(scriptId): SubInspectionApi<string>

Allows modification, retrieval, and event binding of a sub-inspection with the given id.

Parameters
Parameter Type Description
scriptId string Unique id of the sub-inspection.
Returns

SubInspectionApi<string>

An object which allows access to the sub-inspection methods

submitCurrentSubInspection()

submitCurrentSubInspection(suppressConfirmation?): Promise<boolean>

Submits the current sub-inspection, if the sub-inspection is in a valid state. If no sub-inspection is showing, does not do anything.

Parameters
Parameter Type Description
suppressConfirmation? boolean If true, the confirmation dialog displaying "Data submitted successfully" will not appear.
Returns

Promise<boolean>

Whether or not the current sub-inspection was valid to be submitted

uncompleteInspection()

uncompleteInspection(): Promise<void>

Marks the currently running Inspection as "not complete."

The onComplete Inspection event will fire the next time all Sub-Inspections are marked as complete.

Completing the Inspection will cause the currently assigned Accountability Record to be updated with the current Traceability, Part, and Process.

Returns

Promise<void>

updateProperties()

updateProperties(newProps): Promise<void>

Updates the inspection with new values.

Parameters
Parameter Type Description
newProps InspectionWorkerUpdate Object with new properties to use
Returns

Promise<void>