Check database for entry exists and change button text.

Hi All,

I have come to a block with what i’m trying to do, can anyone assist?

I have a databse full of entries. When a user is logged on, i want the button on the ‘My Account’ page to change depending on if they have filled out a form or not.

I have placed my dataset on ‘My Account’ page and set it as Read-Only.

I’m after a peice of code that carrys out the following steps:

  1. Filter the dataset by Owner, to find any entires submitted by the currently logged in user.
  2. If there is an entry, change #button3 to be “Update Your Business” and link to a certain page.
  3. If there is not an entry, change #button3 to be “Register Your Business” and then link to a different page.

Any help would be greatly received.

Tim

Hi Tim,

To filter a dataset by a certain criteria, you can use our wix-data API: wix-data - Velo API Reference - Wix.com
Specifically, take a look at this filter: WixDataFilter - Velo API Reference - Wix.com.

After finding that, you can change a specific button’s label by using our Button API: Button - Velo API Reference - Wix.com.

Good luck,
Idan.

Hi Idan,

How would i add this into a OnReady function and then user the Wix Memebers CurrentUser to filter it?

Tim