In some need of some coding advise.

I’m trying to set-up an exporting data from my collection, but I quite not understand the problem with the value part of this code.


Can someone explain to me, happen going wrong?

Hey there,

The dataset element does not have a value property. That is why you are getting the error.

It looks to me like you might be writing the code from the example in this article: How to Import and Export Collection Data . The code there is retrieving the collection name from an input element on the page.

If you’ve created the form from the example, you want line 4 to be something like:

let collection = $w("#collectionInput").value;

where collectionInput is the ID of the input field on your page that you enter the collection name into.

If you want to do the export without that part of the form, you can hardcode the collection name. That would look something like:

let collection = "collectionName";

where collectionName is the name of your collection.

I am still unable to export my collection.
Here the code:

import wixData from 'wix-data';

export function exportButton_onClick() {
	let collection = "ApplicationForm";
	//: The name of collection I wish to export: ApplicationForm

	wixData.query(collection)
		.limit(1000)
		.find()
		.then((results) => {
			$w("#textBox").value = JSON.stringify(results.items);
		})
		.catch((err) => {
			console.log(err);
		});
}

Hi,

the code looks OK. One thing to check, .value is a property of input boxes, if it is a simple text the property to set is .text.

If you still don’t see JSON in the component, I could check it for you, if you gave me a link to your site.

No is still not work…
Here’s the link of my site: https://arthosmaciel.wixsite.com/wixcode-workflow/copy-of-area-de-membro

Hi,

I see two issues:

  1. It seems that you JS function to handle export button click is not bound to component. What I suggest, is to go to the button properties panel and add a new onClick handler function. Then paste the contents of the old function to the new one.

  2. There is a small mistake in your code:

let collection = $w(“#collectionInput”).value.text;
It should be
let collection = $w(“#collectionInput”).value;

I hope this helps! Let me know.

Thanks, it work now.

1 Like