@noahlovelldesign Lainie is providing you with the core concept that you need to get your arms around.
When you use the wix-user API you need to make sure you are using information from a logged in user.
It might be that your user is already logged in when they reach the page that this code is running on but you need to check this before you go much further.
If your user is not logged in then any user ID that you use will be random and untrustworthy.
Also you need to know if data has been entered before so the best way to do this is get the data you need when the page loads.
The pattern that you need to implement, as I understand your needs is something like this:
create global id variable
create global business data object
onReady
disable submit button
get the current user record
if the current user is logged in then
enable submit button
add the user id from the current user record to the global id variable
get the business properties from the “Properties”
if business properties returned
add business properties to global business data object
load business properties into the input elements displaying returned data
endif
else
tell user to login or register
endif
end onready
onSubmit button click
add new business properties to global business data object
if global business data object user id is null
update global business data object user id with global id variable value
update “Properties” using the global business data object
end onSubmit
A lot of the code you have written will work but you need to update it to include the test for user logged in and don’t allow an update if the user isn’t logged in.
I am happy to help you with more code but thought you might like a chance to make your own modifications.