Form and database options

I am attempting to create a form to collect biological records (bird sightings, etc.) in a database. Records will be entered by members only, but each member might submit tens of records at one time, creating multiple database entries. For this reason I want to make the process as quick and easy as possible. There are a number of things that would help, but I’m struggling to find information on whether any of them are possible:

  1. When a member loads up the form page, can their name be automatically added to the name field? It would need to be editable, as they may enter a record for someone else.

  2. Can other fields (specifically one for ‘location’ of sighting) be autofilled with the value from the previous record submitted by that member (i.e. the location in the last record). It would need to be specific to each member, rather than just the most recent entry in the database. This would save considerable time when entering many sightings for the same site.

  3. Finally, is it possible for a member to view and edit all of the records that they have submitted to the database in the past, but not other people’s?

Unfortunately, my coding experience is limited and out of date, so any explanations might need to be more basic than your average response!

Many thanks in advance.

Hi,

To prefill values, simply change the value of the input box:

$w('#input1').value = 'dave';

you can get the current user by calling wixUsers.currentUser;

Use the same method to prefill the last record location.
Build a data query sorted by last updated to get the most recent record made by the user.

Regarding the last question - to allow users to only edit the records they added you can add a filter to a dataset by setting wixDataset setFilter() .

Thanks for your response. Unfortunately I’m struggling to work out how to code your suggestions. I managed to prefill the field with the user ID, but I really need the user’s name. I successfully created a ‘members’ profile database, using a Wix tutorial, so in theory the member’s name will be held in there once they’ve added it. Presumably the code to prefill the field from another database is relatively easy, but I can’t work it out!

I’m even more stumped by the other two. I can’t seem to find any other examples online that I could tweak to meet my needs.

Sorry, I’m very much a beginner at this!

Thanks

Yes, thank you for the suggestion, Ido!

So having created a collection “Members”, and a field “fullName”, can you please show us how we return the user’s full name after getting the currentUser?

This is literally all I can come up with on my own :-p

import wixUsers from 'wix-users';
 
$w.onReady(function () {
	
wixUsers.currentUser();

});

thanks again!
G