Update collection/Show entered data after Submit

I have a page of info that I am getting from my members (50+ fields). I am able to have them fill out the form and submit. What I need is for it to show the data they submitted when they go back to the form. Also, when they submit, it creates a new row in the collection every time, instead of updating their current row. How can I get this to show their data and also update if they’ve already submitted at least once?

Simply have a look at this tutorial page for a members profile page and update page using two dynamic pages which will be unique to each member.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

You can use it as a starting point and have the profile page as the display all user inputs page and update profile page as the page that they go to to edit, change or add to any of your fifty plus user inputs.

When the update profile page is saved the user inputs are saved back into the dataset and update the site members existing inputs.

Thanks for you reply.

I did see this tutorial before I posted. My issue with that tutorial is that since the Profile Page is a dynamic page, it can only be accessed by clicking a hyperlink or button. I need a page that the members can go to from the menu. They click on that page in the menu and it loads their data and lets them insert/update based on what they’ve previously done.

Thanks

@technology Have a look at Mike’s answer at the end of this previous post about it.
https://www.wix.com/corvid/forum/community-discussion/add-dynamic-page-to-menu

Try it as a workaround and see if it still works.

Hello Technology!

What you are trying to create has more to do with logic & flow than it has to do with code. Don’t get me wrong ---- you WILL be coding, but the solution you need has to do with creating the correct logic & flow for your members.

Essentially you would need 2 forms. One for receiving data for the first time and One for editing the data already received. They can be on the same page or different page ----- but you will still need 2 forms.

To learn one way of creating this, please check out one of my tutorial videos for creating a member’s dashboard area: https://www.youtube.com/watch?v=yLCOqsVHhD0

I’m hitting the same issue with both of these options (the first option, I need the id to get to my dynamic page, the second, option specifically codes for user id), where the get current user id function is returning the owner and not the id.
I have:

import wixUsers from “wix-users”;

$w.onReady( function () {
$w(“#dataset1”).onReady(() => {
let user = wixUsers.currentUser;
let userId = user.id;
console.log("id: " + userId);

)}
)}

This returns:

And in the collection I see:

Both look like viable options, but I need to get the id and not the owner. Any idea why this isn’t returning the correct value?

Thanks!!

It is returning the correct id, it is returning the Owner ID. Your code users the _id field and not the _owner field though.

See here for the difference between the system fields.
https://support.wix.com/en/article/about-your-database-collection-fields#system-fields

As for the Wix tutorial profile page, the user will already be logged into the site so it will already have the current users id through the login lightbox and through the code it checks if there is a member already in the Members collection with the same userid already.

//rest of code....
check if there is an item for the user in the collection
userEmail = email;
return wixData.query("Members")
.eq("_id", userId) 
//rest of code....

That is how it knows how to get to the site members own unique page through the code.

   wixLocation.to(`/Members/${wixUsers.currentUser.id}`);  

It is the same with Nayeli’s updated code for the same tutorial that she has now included the check for the same username is already taken option.

The user will already be logged in through the signup page so you know what the userid of the current user is.

 //rest of code.... 
$w.onReady(function () {
  let user = wixUsers.currentUser;
  let userId = user.id; // "r5cme-6fem-485j-djre-4844c49" 
  let isLoggedIn = user.loggedIn; // true
  user.getEmail() 
 //rest of code.... 

So it will already know the userid of the member and know to take them to that members own account page when they follow the Wix location to call.

wixLocation.to("/account/profile-page");

It might not have the ‘${wixUsers.currentUser.id}’ part as the first tutorial from Wix does, however when it has the page URL of this first ‘/account/’, then you can know that it is still connecting to the logged in members unique member pages only.

This is because if you add the Wix Members app to your site, which Nayeli has done before making that tutorial as it has the Wix Profile Card shown and the pages are listed under the Member Page label in the Site Structure.

Then all those Wix Member app pages that you use on your website will have a leading URL name of /account/ first followed by your page name, so we know that these pages will always be linked to the logged in site member already only.

@givemeawhisky

I appreciate your help with this.

I made a quick video about the issue. Apparently the dynamic page {ID} field is the row id, while the wixUsers.currentUser.id is the owner id. Owner id is not an option for the dynamic page. How can I return the row id in code?

I created a query using the ownerID to find the rowId. I think I’m all set now.

Thank you for your assistance!!