core2-jvm (latest)
core2-jvm (latest)core-jvm
  • Home
  • Features
  • Spec
  • Guides
  • Sandbox
  • Step Studio
  • Step
    • Action
    • External
    • Help
    • Link Handler
    • Navigation
    • Persist Async
    • Polling
    • Refresh On Change
    • Schema On Change
    • Step Error
    • Suggestions
    • Summary
    • Toolbar
    • Upload
    • Validate Async
    • Schema
    • All Of Schema
    • Array Schema
    • Blob Schema
    • Boolean Schema
    • Const Schema
    • Integer Schema
    • Number Schema
    • Object Schema
    • One Of Schema
    • String Schema
    • Layout
    • Alert Layout
    • Box Layout
    • Button Layout
    • Columns Layout
    • Decision Layout
    • Divider Layout
    • Form Layout
    • Heading Layout
    • Image Layout
    • Instructions Layout
    • List Layout
    • Loading Indicator Layout
    • Markdown Layout
    • Media Layout
    • Modal Layout
    • Paragraph Layout
    • Progress Layout
    • Review Layout
    • Search Layout
    • Section Layout
    • Status List Layout
    • Tabs Layout
    • Upsell Layout
    • Behavior
    • Action Behavior
    • Copy Behavior
    • Dismiss Behavior
    • Link Behavior
    • Modal Behavior
    • Refresh Behavior
    • Subflow Behavior
    • Subflow
    • Dynamic Launch Config
    • Launch Config
    • Modal Presentation
    • Native Launch Config
    • Presentation
    • Push Presentation
    • Action Response Body
    • Error Response Body
    • Flow Response
    • Modal Response Body
    • No Op Response Body
    • Search Initial Layout Config
    • Search Initial Results Config
    • Search Initial State
    • Search Layout Response Body
    • Search Response
    • Search Response Body
    • Search Result
    • Search Results Response Body
    • Subflow Response Body
    • Additional Info
    • Align
    • Autocapitalization Type
    • Autocomplete Token
    • Context
    • Icon
    • Image
    • Inline Alert
    • Media
    • Native Capabilities
    • Request
    • Size
    • Supporting Values
    • Control
    • Tag

Persist Async

Android - 8.25.0 iOS - 11539 Web - 2.5.0

Persist Async allows you to submit part of a step asynchronously to an endpoint, then submit an identifier from that asynchronous submission as part of the main step submission. This can be useful in cases where the content of a field is very large (for example file upload), or for if you need to tokenize part of the form for security reasons (e.g. submitting card numbers to a PCI-compliant server).

This functionality is specified using the persistAsync property of a Schema.

Note that the schema on which the persistAsync property is set should reflect the value that is submitted (i.e. the token/identifier), while the [schema] property defines the schema that is shown to the user and submitted to the persist async endpoint.

obj {
    id = "#schema"
    properties {
        string("file") {
            persistAsync {
                url = "/upload"
                method = HttpMethod.POST
                param = "bodyAttribute"
                idProperty = "token"
                schema = BlobSchema.build {
                    source = Upload.Source.FILE
                    title = "Invoice"
                    description = "PNG, JPG, or PDF, less than 5mb"
                    accepts = listOf(
                        "image/png",
                        "image/jpg",
                        "application/pdf"
                    )
                }
            }
        }
    }
}

Example

When the value of the field changes, a request is sent to the URL defined in the persistAsync object, where the request body is a JSON object containing the value of the field under a property matching the value of persistAsync.param.

For example, if the schema was defined as:

Step.build {
    layout { }
    schemas {
        string {
            persistAsync  {
                url = "/persistCard"
                param = "number"
                idProperty = "token"
                schema = StringSchema.build {
                    title = "Card Number"
                }
            }
        }
    }
}

Then a text input titled "Card Number" would be rendered in the form to represent this schema. When the user enters a card number of "1234567890", a POST request would be made to the /persistCard endpoint with the following body:

{
  "number": "1234567890"
}

On success, the response body should be a JSON object which contains an identifier that should be used in the main submission under the property specified in persistAsync.idProperty - for example:

{
  "token": "ce0a93b2-f11d-49a4-ab02-705bb66f5b39"
}

When the user submits the form, the submission will contain this identifier as the value of the schema.

Error Handling

In the case of an error, the standard Step Error response can be used.

In the card example above, the server could respond as follows with a non-2xx status code to show an error on the card number field:

{
  "validation": {
    "number": "This card number is invalid"
  }
}

If a persist async call fails, the client should re-attempt it on the next form submission. A failure should prevent submission and display an error to the user.

Properties

PropertyTypeRequiredDescription
idPropertyStringYesThe name of the property under which the value used in the main submission can be found in the response body.
methodStringYesThe HTTP method used for the async submission. Defaults to POST.
paramStringYesThe name of the property under which the value of the schema will be sent in the request body.
schemaSchemaYesThe schema which will be shown to the user, and whose value will be sent in the Persist Async submission.
urlStringYesThe URL used for the async submission.