How to update values of 1 existing collection field via CSV import

Hi

I am trying to update values of a single field in a collection by exporting the entire collection to CSV, updating values of a single field, then importing just the ID and relevant field (lets call it Field X) to my collection.

My problem is that when I select the option to “Replace with imported items” as an option when configuring the import of the ID field, ALL other fields and data are deleted! (I guess because I am only importing 2 of the original fields?) . If I select “Do not import items” as an option the Field X data remains unchanged.

So can you advise the correct procedure to import 1 column/field into a collection, to update / overwrite the existing data in that field, whilst leaving all other data untouched?

A possible workaround could be to export the whole collection, change the data in the Field X, then import the entire collection again to overwrite it. However I can’t do this as the other fields are user generated, so in the time I export, amend and re-import some user data may have changed and so I would be overwriting these changes with old data.

Another method may be to import the amended Field X data into its own collection and link it to the original collection somehow. But I dont know how to achieve this (and it is a more complicated version of the first and preferred option).

Note I am testing this in Sandbox to prevent overwriting live data.

Any assistance would be appreciated.
Thanks

You should be able to simply import the csv and import whatever you wish to import into a dataset whether that be in sandbox or live, just as long as you have already published your website so the dataset is live.

Also, have a read as you mention about ID field…
https://support.wix.com/en/article/about-importing-data-in-the-data-manager

About Updating Existing Items
You can update existing items in your database collection by importing data from a CSV file that includes the item IDs. The easiest way to do this correctly is to make sure to include the ID field when exporting the data.

  • If your database collection already contains items with those IDs, you can choose whether to overwrite them with the data from your CSV file or to skip them.

  • If your database collection does not contain items with those IDs, the rows are added as new items, using the IDs listed in your CSV file.

About Field Types
You can import any field type into your database collection, except for the following:

  • Fields that link to dynamic pages.

  • System fields other than the ID field.

  • Document fields, unless they link to documents that already exist in your media manager.

  • Image fields, unless they link to images that already exist in your media manager.
    Note that the data is not validated when you import it. You must make sure that your data in your CSV file matches the field types in your collection.

When importing reference fields, it is important to know that the information that is stored in the collection is the ID from the id System Field of the referenced item.

Have a read too of the link for the id System Field and it will mention about ID:
https://support.wix.com/en/article/about-your-database-collection-fields#system-fields

  • A unique identifier for the item. You can assign the ID a value when you import new data from a CSV file. Otherwise the ID is a random UUID.

  • Using Wix Code you can also assign the ID a value when adding items with the Data API.

  • Once defined the ID cannot be edited.

Finally, whilst at it, have a read of Non-structure fields too:
https://support.wix.com/en/article/about-the-structure-of-your-database-collection#non-structure-fields

  • Non-structure fields are fields that are displayed in your your collection but are not actually part of your database.

Hi

Thanks for the quick response. I’ve previously read most of what you have linked - the only new info I can see is that Field X is actually linked to a dynamic page - so this means I cannot update this data? Can you advise a workaround to update this information?

Also I still don’t understand why when importing only 1 of many existing fields all other fields’ data is deleted. Is this normal behaviour?

How about doing it via google sheets and zapier? I have just pm’d you an example to check out.

Hi Jaosh, please respond if you get this msg. I have a similar requirement, may need this solution.

PLEASE !!!

ANSWER THE QUESTION !!!

HOW TO UPDATE JUST ON FIELD IN A COLLECION IMPORTING FROM CSV FILE

2 YEARS FOR AN ANSWER !!! REALLY !!!

//I don't know if it will help but. I found such a solution to update only a specific field in //a collection.
//Suppose the field to be changed is phone only
let phone = $w('#phoneInput').value

//For example : The row id you want to change
let rowId = "bfc331e0-9459-4169-b8ae-1fde956caefc"

wixData.query('yourCollection')
.eq('_id', rowId)
.find()
.then((results)=>{
	if(results.totalCount > 0){
		let title= results.items[0].title
		let firstName= results.items[0].firstName
		let lastName= results.items[0].lastName
		let email= results.items[0].email

		let toUpdate = {
			_id: rowId ,
			title: title,
			firstName: firstName,
			lastName: lastName,
			email: email,
			phone: phone 
		}

		wixData.update('yourCollection', toUpdate)
			.then((result)=>{
			console.log(result)
		})
      }		
})