Contents

onAssignedDocumentWillSubmit(_:)

Adds an action to perform before submitting an assigned document.

Declaration

@MainActor @preconcurrency func onAssignedDocumentWillSubmit(_ action: @escaping  @Sendable (URL) async -> Bool) -> some View

Parameters

  • action:

    An asynchronous closure that receives the document URL and returns a Boolean value indicating whether to proceed with submission. Return true to continue, or false to cancel.

Return Value

A view that executes the specified action before assigned document submission.

Discussion

Return true to allow the submission to proceed, or false to cancel the submission. This is useful for validating document content, confirming user intent, or performing prerequisite operations.

AssignedDocumentSubmissionButton(documentURL: documentURL)
    .onAssignedDocumentWillSubmit { url in
        // Validate the assigned document before submission
        guard await isDocumentComplete(url) else {
            await showAlert("Please complete all sections before submitting")
            return false // Prevents submission
        }
        return true // Allows submission to continue
    }

See Also

Submission