Static
validateA static method available on the forms class, used for validating a api request configuration.
const endpointConfiguration = {
type: 'CALLBACK',
configuration: {
url: 'https://a-website.com/endpoint',
},
}
const result = OneBlink.Forms.validateEndpointConfiguration(
endpointConfiguration,
)
if (!result.success) {
throw result.error
}
const validatedEndpointConfiguration = result.data
return validatedEndpointConfiguration
Minimum Role Permission
Forms: Manager
The form object to create.
forms
.createForm({
name: 'testsform',
formsAppEnvironmentId: 1,
description: 'a form',
organisationId: '0101010101010',
formsAppEnvironmentId: 1,
elements: [],
isAuthenticated: false,
submissionEvents: [],
postSubmissionAction: 'FORMS_LIBRARY',
formsAppIds: [1, 2, 3],
})
.then((form) => {
// use form here
})
.catch((error) => {
// Handle error here
})
Minimum Role Permission
Upload Attachments: On
The attachment to upload
The attachment's file content to upload
The attachment's content type
The attachment's file name
The exact id of the form the attachment will be uploaded for
Determine if this attachment can be downloaded anonymously (false
) or
not (true
)
Optional
username?: stringAn optional username to allow a single user to download he attachment file
const fs = require('fs')
const util = require('util')
const readFileAsync = util.promisify(fs.readFile)
async function run() {
const formId = 1
const imageFileName = 'profile-picture.png'
const imageBuffer = await readFileAsync(imageFileName)
const imageResult = await forms.createSubmissionAttachment({
formId,
body: imageBuffer,
isPrivate: false,
contentType: 'image/png',
fileName: imageFileName,
})
const documentFileName = 'secrets.text'
const readableStream = fs.createReadStream(documentFileName)
const documentResult = await forms.createSubmissionAttachment({
formId,
isPrivate: true,
contentType: 'text/plain',
fileName: documentFileName,
body: readableStream,
username: 'user@example.com',
})
}
Minimum Role Permission
Submission Data: Manager
An object containing all parameters to be passed to the function
The form identifier for the workflow event you want to replay
The submission identifier for the workflow event you want to replay
The configuration of the workflow event you want to replay
const parameters = {
formId: 1,
submissionId: 'c1f0f27b-4289-4ce5-9807-bf84971991aa',
workflowEvent: {
type: 'PDF',
configuration: {
toEmail: ['{ELEMENT:Email}'],
emailSubjectLine: 'Email Subject',
excludedElementIds: [],
},
},
}
forms
.executeWorkflowEvent(parameters)
.then(() => {
// Workflow event has been executed
})
.catch((error) => {
// Handle error here
})
App Association Required
Minimum Role Permission
Upload Form Prefill Data: Manager (only if using preFillData
)
An object containing all parameters to be passed to the function
Optional
expiryThe time in seconds until the generated form URL is no longer valid. This
is set to 28800
seconds (8 hours) by default.
Optional
externalThe external identifier of the form submission you wish to use, this identifier will be returned to you with the submissionId after a successful submission to allow you to retrieve the data later
The exact id of the form you wish to generate a URL for
Optional
formsThe exact id of the forms app you wish to generate a URL for. This is set to the first forms app the form was added to by default.
Optional
preAn object with the form field names as keys and the prefill data as the values
Optional
previousThe exact id of the previous form submission approval this submission will be associated to
Optional
username?: stringAn identifier for the user completing the form. Including this property will add the username to the access token. Use this if you would like to securely know the user that submitted the form in a webhook.
const parameters = {
formId: 1,
formsAppId: 2,
externalId: 'My Custom Identifier',
preFillData: {
FieldName1: 'A Machine',
FieldName2: 'Room B',
},
expiryInSeconds: 36800,
username: 'username',
secret: 'sshh',
previousFormSubmissionApprovalId: 1,
}
forms.generateFormUrl(parameters).then((result) => {
const formUrl = result.formUrl
// Use form URL here...
})
Generate a url to download an attachment. The expiration of the URL is
determined by input parameters and only last a maximum of 12 hours. This
should be used for short lived URLs that will be used immediately. If you
require a URL that needs to last longer, consider using the
generateWorkflowAttachmentLink()
function.
Submission Data Key Supported
Key must be assigned to the form that the attachment was uploaded for.
Minimum Role Permission
Submission Data: Read Only
The exact id of the form you wish to generate a URL for
The attachment identifier from the form submission data
The number of seconds the signed URL should be valid
for, must be greater than or equal to 900
An absolute URL that that can be used to download the attachment
Submission Data Key Supported
Key must be assigned to the form that was submitted.
Minimum Role Permission
Submission Data: Read Only
The exact id of the form you wish to generate a URL for
The submission identifier generated after a successful form submission, this will be return to you after a successful forms submission via a callback URL
The number of seconds the signed URL should be valid
for, must be greater than or equal to 900
Generate a workflow attachment link for an attachment. The expiration of
the link is configured for the account and cannot be changed for generated
links. If you require a URL that should be short lived, consider using the
generateSubmissionAttachmentUrl()
function.
Submission Data Key Supported
Key must be assigned to the form that the attachment was uploaded for.
Minimum Role Permission
Submission Data: Read Only
The options required to generate a link
The attachment identifier from the form submission data
The exact id of the form you wish to generate a URL for
The submission identifier for the the form submission
An absolute URL that that can be used to download the attachment
Submission Data Key Supported
Key must be assigned to the form that was submitted.
Minimum Role Permission
Submission Data: Read Only
The exact id of the submission you wish to get the meta result for
Submission Data Key Supported
Key must be assigned to the form that the attachment was uploaded for.
Minimum Role Permission
Submission Data: Read Only
The exact id of the form the attachment was uploaded on
The attachment identifier from the form submission data
const fs = require('fs')
const util = require('util')
const writeFileAsync = util.promisify(fs.writeFile)
async function run() {
const formId = 1
const attachmentId = 'c1f0f27b-4289-4ce5-9807-bf84971991aa'
const buffer = await forms.getSubmissionAttachmentBuffer(
formId,
attachmentId,
)
await writeFileAsync('file.png', buffer)
}
Submission Data Key Supported
Key must be assigned to the form that was submitted.
Minimum Role Permission
Submission Data: Read Only
The exact id of the form the attachment was uploaded on
The attachment identifier from the form submission data
Submission Data Key Supported
Key must be assigned to the form that the attachment was uploaded for.
Minimum Role Permission
Submission Data: Read Only
The exact id of the form the attachment was uploaded on
The attachment identifier from the form submission data
const fs = require('fs')
const util = require('util')
const stream = require('stream')
const finishedAsync = util.promisify(stream.finished)
async function run() {
const formId = 1
const attachmentId = 'c1f0f27b-4289-4ce5-9807-bf84971991aa'
const readableStream = await forms.getSubmissionAttachmentStream(
formId,
attachmentId,
)
const writableStream = fs.createWriteStream('file.png')
readableStream.pipe(writableStream)
await finishedAsync(readableStream)
writableStream.end()
}
Submission Data Key Supported
Key must be assigned to the form that was submitted.
Minimum Role Permission
Submission Data: Read Only
The exact id of the form you wish to get submission data for
The submission identifier generated after a successful form submission, this will be return to you after a successful forms submission via a callback URL
true
if the submission is a draft submission, otherwise
false
const formId = 1
const submissionId = 'c1f0f27b-4289-4ce5-9807-bf84971991aa'
const isDraft = false
forms
.getSubmissionData(formId, submissionId, isDraft)
.then((result) => {
const definition = result?.definition
const submission = result?.submission
})
.catch((error) => {
// Handle error here
})
Minimum Role Permission
Forms: Manager
Migration options
forms
.migrateForm({
formsAppEnvironmentId: 2,
sourceFormId: 123,
targetFormId: 234,
elements: true,
approvalSteps: false,
submissionEvents: false,
tags: true,
approvalSteps: false,
serverValidation: false,
externalIdGenerationOnSubmit: false,
personalisation: false,
postSubmissionAction: false,
embeddedForms: [
{
sourceElementId: 'acbd',
targetFormId: 678,
},
],
approvalForms: [
{
stepLabel: 'Approve',
targetFormId: 53,
},
],
versionId: 5,
})
.then((migratedForm) => {
// do something with form
})
.catch((error) => {
// Handle error here
})
Minimum Role Permission
Forms: Read Only
Optional
searchParams: FormsSearchOptionsSearch options.
Search for details on submissions that match the search parameters. Then use the information to fetch the actual submission data, if it is still available
Submission Data Key Supported
Results will be restricted to forms that have been assigned to the Key.
Minimum Role Permission
Submission Data: Read Only
Search options.
const options = {
formId: 1,
submissionDateFrom: '2018-08-16T05:28:26.448Z',
submissionDateTo: '2019-08-16T05:28:26.448Z',
isValid: true,
submissionTitle: 'Smith',
}
forms
.searchSubmissions(options)
.then((result) => {
const submissionDetails = result.formSubmissionMeta
return Promise.all(
submissionDetails.map((metaData) =>
forms.getSubmissionData(
metaData.formId,
metaData.submissionId,
),
),
)
})
.then((submissions) => {
// something...
})
.catch((error) => {
// Handle error here
})
Minimum Role Permission
Forms: Manager
The form object to update
Optional
overrideLock: booleanDefaults to false
. Set to true to force updating of
the form if the form is locked via the form builder
forms
.updateForm(
{
id: 1,
name: 'testsform',
formsAppEnvironmentId: 1,
description: 'a form',
organisationId: '0101010101010',
formsAppEnvironmentId: 1,
elements: [],
isAuthenticated: false,
submissionEvents: [],
postSubmissionAction: 'FORMS_LIBRARY',
formsAppIds: [1, 2, 3],
},
true,
)
.then((form) => {
// use form here
})
.catch((error) => {
// Handle error here
})
Upload a file to use as an attachment for an email based form workflow event.
Minimum Role Permission
Upload Attachments: On
Available options for uploading attachment.
The attachment's file content to upload
The attachment's content type
The attachment's file name
The configuration required to add custom attachments to an email.
Static
generateA static method available on the forms class, used for both creating and validating a OneBlink Form Element.
The method will set reasonable defaults for any values not passed to it, and validate ones that are against our Element Schema.
Optional
formElementGenerationData: Record<string, unknown>Static
generateA static method available on the forms class, used for both creating and validating a OneBlink Page Element.
The method will set reasonable defaults for any values not passed to it, and validate ones that are against our Element Schema.
Optional
formElementGenerationData: Record<string, unknown>Static
validateA static method available on the forms class, used for validating a OneBlink compatible Forms Definition.
The form object to validate.
const form = {
id: 1,
name: 'testsform',
formsAppEnvironmentId: 1,
description: 'a form',
organisationId: '0101010101010',
elements: [],
isAuthenticated: false,
submissionEvents: [],
postSubmissionAction: 'FORMS_LIBRARY',
formsAppIds: [1, 2, 3],
}
const result = OneBlink.Forms.validateForm(form)
if (!result.success) {
throw result.error
}
const validatedNewForm = result.data
return validatedNewForm
Static
validateA static method available on the forms class, used for validating a OneBlink Form Event.
The form elements to validate against the event
The untrusted data to validate
A trusted form event
Example