updateSubmission( )
Updates a submission.
Note: The Submissions API is only available in Wix Studio and Editor X.
Description
Each time the submission is updated, revision
increments by 1. The existing revision
must be included when updating the submission. This ensures you're working with the latest submission information, and prevents unintended overwrites.
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function updateSubmission(_id: string, submission: UpdateSubmission): Promise<FormSubmission>
updateSubmission Parameters
NAME
TYPE
DESCRIPTION
Submission ID.
Submission to update.
Returns
The updated submission.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the form submission was created.
Submission ID.
Date and time the form submission was updated.
Data extension object that holds users' and apps' fields.
ID of the form which the submission belongs to.
The app which the form submissions belong to. For example, the namespace for the Wix Forms app is wix.form_app.form
. Call Get Submission
to retrieve the namespace.
Order details.
Note: This object is only applicable when submittng a form in the Wix Payments app.
Revision number, which increments by 1 each time the form submission is updated. To prevent conflicting changes, the existing revision must be used when updating a form submission.
Whether a site owner marked a submission as "seen".
Status of the submission.
PENDING
: A submission is created, but has not yet been recorded in the Wix Forms collection.PAYMENT_WAITING
: A form submission requiring payment is created.PAYMENT_CANCELED
: An order of a form submission is canceled.CONFIRMED
: A submission is recorded in the Wix Forms collection.
Submission values where key
is the form field and value
is the data submitted for the given field.
ID of the visitor that submitted the form.
Was this helpful?
1import { submissions } from 'wix-forms.v2';23/*4Sample _id value: "abb9b5c9-a881-467c-9c34-b9bea43ca5f0"5Sample submission value:6{7 "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",8 "seen": false,9 "status": "CONFIRMED",10 "revision": "6",11 "submissions": {12 "first_name": "Jane",13 "last_name": "McBride"14 }15}16*/1718export async function myUpdateSubmissionFunction(_id, submission) {19 try {20 const updatedSubmission = await submissions.updateSubmission(_id, submission);21 console.log('Success! Updated submission:', updatedSubmission);22 return updatedSubmission;23 } catch (error) {24 console.error(error);25 // Handle the error26 }27}2829/* Promise resolves to:30{31 "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",32 "namespace": "wix.form_app.form",33 "status": "CONFIRMED",34 "submissions": {35 "last_name": "McBride",36 "first_name": "Jane"37 },38 "revision": "6",39 "submitter": {40 "applicationId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"41 },42 "seen": false,43 "_id": "abb9b5c9-a881-467c-9c34-b9bea43ca5f0",44 "_createdDate": "2023-12-28T12:54:04.652Z",45 "_updatedDate": "2023-12-28T14:33:02.571Z"46}47*/
1import { Permissions, webMethod } from 'wix-web-module';2import { submissions } from 'wix-forms.v2';3import { elevate } from 'wix-auth';45/*6Sample _id value: "abb9b5c9-a881-467c-9c34-b9bea43ca5f0"7Sample submission value:8{9 "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",10 "seen": false,11 "status": "CONFIRMED",12 "revision": "6",13 "submissions": {14 "first_name": "Jane",15 "last_name": "McBride"16 }17}18*/1920export const myUpdateSubmissionFunction = webMethod(Permissions.Anyone, async (_id, submission) => {21 try {22 const elevatedUpdateSubmission = elevate(submissions.updateSubmission);23 const updatedSubmission = await elevatedUpdateSubmission(_id, submission);24 console.log('Success! Updated submission:', updatedSubmission);25 return updatedSubmission;26 } catch (error) {27 console.error(error);28 // Handle the error29 }30});3132/* Promise resolves to:33{34 "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",35 "namespace": "wix.form_app.form",36 "status": "CONFIRMED",37 "submissions": {38 "last_name": "McBride",39 "first_name": "Jane"40 },41 "revision": "6",42 "submitter": {43 "applicationId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"44 },45 "seen": false,46 "_id": "abb9b5c9-a881-467c-9c34-b9bea43ca5f0",47 "_createdDate": "2023-12-28T12:54:04.652Z",48 "_updatedDate": "2023-12-28T14:33:02.571Z"49}50*/51