Search.../

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.

Admin Method

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
_id
string

Submission ID.

submission
UpdateSubmission

Submission to update.

Returns

The updated submission.

Return Type:

Promise<
FormSubmission
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the form submission was created.

_id
string

Submission ID.

_updatedDate
Date

Date and time the form submission was updated.

extendedFields
ExtendedFields

Data extension object that holds users' and apps' fields.

formId
string

ID of the form which the submission belongs to.

namespace
string

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.

orderDetails
OrderDetails

Order details.
Note: This object is only applicable when submittng a form in the Wix Payments app.

revision
string

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.

seen
boolean

Whether a site owner marked a submission as "seen".

status
string

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.
submissions
Object

Submission values where key is the form field and value is the data submitted for the given field.

submitter
Submitter

ID of the visitor that submitted the form.

Was this helpful?

Update a submission (dashboard page code)

Copy Code
1import { submissions } from 'wix-forms.v2';
2
3/*
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*/
17
18export 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 error
26 }
27}
28
29/* 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*/
Update a submission (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { submissions } from 'wix-forms.v2';
3import { elevate } from 'wix-auth';
4
5/*
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*/
19
20export 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 error
29 }
30});
31
32/* 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