Started playing with Wix Code this weekend, Impressive for a Beta-version. Have not encountered a fatal error yet. So congrats on this much needed effort.
I am prototyping a Properties db with is used in the following way (more or less like booking.com)
- site visitor sees list of available properties (hotels, etc). Status: working. Grid and link to Properties Dynamic Page for details
2)only the property owner should be able to update his own record. Status: not working.
I have set it up as follows:
- permissions on DB as follows
2) created a ‘Member login’ text link in site’s footer. This hard links to a Dashboard-like page (access = members only, have to be approved)
3) a button on this dashboard links to a editable form (dataset set to read/write)
Problem: when I select this Page in the Button properties, a second field pops up, a drop down, asking me to select the record that has to be edited.
But that is not what I want: I want the logged-in user (owner) to be able to edit his-and-only-his record.
So somehow a connection should be made between logged-in user ID and his (unique) Property.record. I found an owner ID in every record in the Wix Db Manager (the grid), but I do not see how it is possible to link the two together dynamically.
Is this possible?
Hi Giri,
thanks for the feedback.
could you post some screenshots, or better a video clip, of the scenario you described?
thanks.
Sure can.
- examples of grid in dev and user mode, with details Dynamic Page
(That nicely formated date in the grid is now displayed as a crzay date, but thats´s another matter)
2)Dashboard Page after member login. Here´s where I have to select to which Property it links, but I don´t want that, I want it to be the ONLY record that this user owns.
- I see an owners in every record. No idea who this is. But somehow that should be the only one being able to do the editing. I prob. own this record and I logged in using a diferent user, but I can still do what the Dataset permissions allow (read/write) on the record that was selected in the button properties.
Thanks for your help, hope this is enough.
Hey Giri,
I think I follow what you want to do and can point you in the right direction.
The reason you are getting that extra dropdown asking you which item you want to link to is because you created your form on a dynamic page. When you hard link to a dynamic page the system needs to know which item you want it to display. (If you were to link from a table or gallery that is set up to link to a dynamic item page then it would know which item to display automatically).
The thing is, your form shouldn’t be in a dynamic page because you want to find data based on the logged in user, not based on the URL. Use a dynamic page only when the URL is what drives the data you want to work with.
What you want to do is:
-
Create your form on a static/regular page.
-
Add a dataset to the page.
-
Use this API to set up your dataset so it filters for your current logged in member’s collection item: https://www.wix.com/code/reference/wix-dataset.html#setFilter
-
Now you can use databinding to connect your elements to your collection.
We have a tutorial that walks you through creating a user input form on a regular page. You probably need to start at step 4: Velo Tutorial: Creating a Form for Editing Data in a Database Collection | Help Center | Wix.com
Let us know how this goes.
Thank you, I will give this a go. One other question, though: this filter has to be applied on an existing query def (dataset), which you ref by its name. But it should be added to the query before it is run. SO I looked up the dataset doc, but I cannot find something like “BeforeExecuteQuery”. So, where do I put the code?
you can put in the dataset’s onReady() event handler.
this will reload the dataset with the new filter.