SvelteKit Form Action plus Netlify Form Submission

Hello

I was able to successfully setup my form to receive and see the submissions in the Netlify Form Dashboard. After that, I have implemented a custom SvelteKit Form Action to POST the form data to a database. But now the submissions don’t appear in the Netlify Form Dashboard anymore.

The form is still being detected successfully and is set as active.

I have a custom redirect in the +page.server.js file to a /success page.

Any hints, ideas on where I can start looking is appreciated.

My site is: https://r1--suhrteig.netlify.app

Thank you! :slight_smile:

Any reason why you didn’t use the submission-created function: Forms and Functions?

If SvelteKit is handling the form submissions, Netlify won’t be receiving those.

Thanks for your reply :slight_smile:

It’s the first time I’m trying to implement a form that posts to a database. So I was trying to use the Svelte Form Action to post to the database, and use the built in Netlify form functionality for easy e-mail notifications when a form is submitted. In case if one would fail, I would still see the submission in one place or the other.

So I tried it through a submission-created.js but it’s not posting to the database anymore. Any idea where it’s failing? Submissions arrive in the Netlify Form Dashboard though, so that works again :slight_smile:

const {Client} = require("@notionhq/client")

exports.handler = async function (event) {
	const notion = new Client({ auth: process.env.SECRET_NOTION_TOKEN });
	const formData = JSON.parse(event.body).payload.data;

	const formName = formData.get("form-name");
	const name = formData.get("name");
	const email = formData.get("email");
	const address = formData.get("address");
	const order = formData.get("order");
	const total = formData.get("total");
	const note = formData.get("note") === "" ? "—" : formData.get("note");
	const delivery = formData.get("delivery");
	const confirm = formData.get("confirm");

	const new_row = {
		parent: {
			type: "database_id",
			database_id: process.env.SECRET_DATABASE_ID,
		},
		properties: {
			Name: {
				title: [
					{
						text: {
							content: name,
						},
					},
				],
			},
			Email: {
				email: email,
			},
			Address: {
				rich_text: [
					{
						text: {
							content: address,
						},
					},
				],
			},
			Order: {
				rich_text: [
					{
						text: {
							content: order,
						},
					},
				],
			},
			Total: {
				number: parseFloat(total),
			},
			Note: {
				rich_text: [
					{
						text: {
							content: note.toString(),
						},
					},
				],
			},
			Delivery: {
				select: {
					name: delivery,
				},
			},
			Confirm: {
				checkbox: JSON.parse(confirm),
			},
		},
	};
	await notion.pages.create(new_row);
	return {
		statusCode: 200,
	};
};

Hi @refchef ,

Glad to hear submissions are working on Netlify Form Dashboard! Troubleshooting Svelte Form Action does fall outside of our support scope. We recommend taking a look at Svelte docs or reaching out to their support to troubleshoot their form action Form actions • Docs • SvelteKit