Is there a way to do a complete copy of a CMS table (FieldNames, FIeldIDs, Data)
Product:
Wix Studio
What are you trying to achieve:
I would like to duplicate a collection so I can add and remove some fields with out loosing the data
What have you already tried:
I have tried to export to a CVS but this feature only exportes the Filed Name .
Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]
First export the entire collection. Use the top check box to do this. do not exclude anything here.
This will export all field names and data.
The create a new cms. from scratch.
Give it a name.
Click the Create button.
A blank new collection should open.
While in the collection, open the More Actions menu and select the Import from csv.
Choose the csv file you just exported. Once uploaded, you will be given a Configure Columns to Import. dialogue.
You use this to only import the columns/fields you want.
Uncheck any field you do not want to import. You will see it also confirms a field uncheck will not be imported.
This is also the place to make sure the any fields that are not meant to be Text fields are set ti the correct type. Fields like Time, Number, Multi Ref.
Here as shown this Show End Time field should be of type ‘Time’
Select each field and make sure it is right. Here I have corrected its type
t will be possible to do it later if you do not do this at this stage, but it will be a pain in the … if you have a lot of entries.
Click next, and review you choices. Once happy import.
Add any new fields you may need now.
Thank you Mark for your prompt response.
The problem with this procedure is field_ID i not imported. I have to manually, check each field_ID and change it.
Is there another way doing it with code?
I was trying to do a copyDB() function with wix-data.v2, but I got stuck with the elevate() auth, since I couldn’t find a wix example for the wix-data.v2.
Do you have any code on how to use the elevate() function on a createDataCollection and or getDataCollection?
Thanks in advance!!!
Best regards,
I can only assume at this stage you are creating your own id field when you are not seeing them and therefore have to manually enter them!
They do import but are not shown by default.
Simply use the manage Fields button and you will see it at the top of the field list
unchecked. Simply check the check box if you want it visible Or keep it hidden from your view if you don’t.
Thanks Mark for your prompt response, but I’looking a way to import the key field, almost all my filed keys are customized.
Is possible to do it by code?
I was checkin on wix-data.v2 trying to get collection structure with listDataCollections() and then createDataCollection(), but it needs the Permissions and webMethod to be imported from wix-web-module, when I include this line in the backend.jsw file it shows a red line under wix-web-module saying … Cannot find module ‘ wix-web-module’ or its corresponding type declarations.
By any chance do you have a sample code to do a Collection copy with some code like this or something that will enable me to Copy the entire collection by code?
Thanks in advance
Best regards,
I will PM you, to get some clarification.
It is a little unclear what your goal is to me…
I probably can show you code on how to copy a cms but there would be no point until I fully understand the issue.
( will come back here with answers for later viewers)
Thanks Mark,
Let me show you some code I’ve wrote, this will help to explain better what I want to accomplish.
import { copyDB} from ‘backend/gapi’;
$w(‘#button24’).onClick((event) => {
copyDB(“collectionName”);
})
----- backend/gapi -----
import { collections } from “wix-data.v2”;
export async function copyDB(stDBname ) {
try {
const dataCollectionId = stDBname;
const stNewDBstruc = await myGetDataCollectionFunction(dataCollectionId);
stNewDBstruc._id = “newDB”;
const stCreationResult = await myCreateDataCollectionFunction(stNewDBstruc);
} catch (error) {
console.error(error);
}
}
export async function myCreateDataCollectionFunction(newCollection) {
try {
const createDataCollectionResponse =
await collections.createDataCollection(newCollection);
return createDataCollectionResponse;
} catch (error) {
console.error(error);
}
}
export async function myGetDataCollectionFunction(dataCollectionId) {
try {
const retrievedCollection =
await collections.getDataCollection(dataCollectionId);
return retrievedCollection;
} catch (error) {
console.error(error);
// Handle the error
}
}
I hope this will help
best regards
Hi Mark,
Still waiting for your help…
Can you share some code to copy a collection with code?
Best regards,
Hi, I did PM you!, but got no response?
Im sorry, didn’t get your message, I have been waiting here for the response.
Where I can see your PM?
Best regards
Mark is probably referring to the private messages in the account menu. I believe your account menu also has a mail icon—do you see any notifications there? 
Thanks, I found the PM message, sorry!, new in this platform
Best regards