> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: createSubmission(submission: FormSubmission, options: CreateSubmissionOptions) # Method package: wixFormsV2 # Method menu location: wixFormsV2 --> submissions --> createSubmission # Method Link: https://dev.wix.com/docs/velo/apis/wix-forms-v2/submissions/create-submission.md # Method Description: Creates a submission. The `createSubmission()` function is an alternative way to the [`WixFormsV2`](https://www.wix.com/velo/reference/$w/wixformsv2/submit) element for submitting a form. In this case, clicking the submit button is unnecessary, the submission is automatically created when calling this function. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create a submission ```javascript import { submissions } from 'wix-forms.v2'; /* Sample submission value: { "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03", "seen": false, "status": "PENDING", "submissions": { "first_name": "Patsy", "last_name": "McBride" } } */ export async function myCreateSubmissionFunction(submission, options) { try { const createdSubmission = await submissions.createSubmission(submission, options); console.log('Success! Created submission:', createdSubmission); return createdSubmission; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: { "submission": { "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03", "namespace": "wix.form_app.form", "status": "PENDING", "submissions": { "first_name": "Patsy", "last_name": "McBride" }, "revision": "1", "submitter": { "applicationId": "151e476a-715e-ec33-db9a-a7ff4d51f70a" }, "seen": false, "_id": "f8281b62-1b2f-45bf-ba7d-f041d7653d2d", "_createdDate": "2023-12-28T12:55:55.630Z", "_updatedDate": "2023-12-28T12:55:55.746Z" } } */ ``` ## Create a submission (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { submissions } from 'wix-forms.v2'; import { elevate } from 'wix-auth'; /* Sample submission value: { "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03", "seen": false, "status": "PENDING", "submissions": { "first_name": "Patsy", "last_name": "McBride" } } */ export const myCreateSubmissionFunction = webMethod(Permissions.Anyone, async (submission, options) => { try { const elevatedCreateSubmission = elevate(submissions.createSubmission); const createdSubmission = await elevatedCreateSubmission(submission, options); console.log('Success! Created submission:', createdSubmission); return createdSubmission; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: { "submission": { "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03", "namespace": "wix.form_app.form", "status": "PENDING", "submissions": { "first_name": "Patsy", "last_name": "McBride" }, "revision": "1", "submitter": { "applicationId": "151e476a-715e-ec33-db9a-a7ff4d51f70a" }, "seen": false, "_id": "f8281b62-1b2f-45bf-ba7d-f041d7653d2d", "_createdDate": "2023-12-28T12:55:55.630Z", "_updatedDate": "2023-12-28T12:55:55.746Z" } } */ ``` ## Create a submission with a media file ```javascript /************************************** * Backend code - my-backend-file.web.js * *************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { submissions } from 'wix-forms.v2'; import { elevate } from 'wix-auth'; // Get a URL for uploading a media file export const myGetMediaUploadUrlFunction = webMethod(Permissions.Anyone, async (formId, filename, mimeType) => { try { const elevatedGetMediaUploadUrl = elevate(submissions.getMediaUploadUrl); const uploadUrl = await elevatedGetMediaUploadUrl(formId, filename, mimeType); return uploadUrl; } catch (error) { console.error(error); // Handle the error } }); // Create a submission export const myCreateSubmissionFunction = webMethod(Permissions.Anyone, async (submission, options) => { try { const elevatedCreateSubmission = elevate(submissions.createSubmission); const createdSubmission = await elevatedCreateSubmission(submission, options); return createdSubmission; } catch (error) { console.error(error); // Handle the error } }); /************* * Page code * ************/ import { myCreateSubmissionFunction, myGetMediaUploadUrlFunction } from 'backend/my-backend-file.web'; const submission = { "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03", "seen": false, "revision": "6", "submissions": { "first_name": "Jane", "last_name": "McBride", "file_upload_7a7f": "" } } const formId = "21bcb6c7-02b3-4ed1-b6db-7856094fac03" const filename = "photo.jpg" const mimeType = "image/jpg" $w.onReady(() => { myGetMediaUploadUrlFunction(formId, filename, mimeType).then((result) => { submission.submissions.file_upload_7a7f = result.uploadUrl // push the URL into the submissions object }); /* Upload a media file to the generated URL by following the information written in the Upload API (https://www.wix.com/velo/reference/wix-media-v2/upload-api) article. */ myCreateSubmissionFunction(submission).then((result) => { console.log('Success! Created submission:', result); }); }); ``` ---