Hi,
The other fields in the record are being updated? or is it only the fullName that doesn’t update correctly?
You can use console.log to check if the hook is being called. check out this post
That dataset might be from a different page. There are other pages where the permissions allow for writing, and the records in the collection update. Everything except for the field in the hook.
I’m replying from my phone right now, so it’s hard to give the exact page.
I cloned your site so I could play with it without interfering with your work, but I haven’t been able to figure out how to register/login/whatever to your site. I’ve got part of it, but apparently not enough for the input fields on the CoachInfo page to be enabled.
You might have an issue with permissions on the collection. This is what I see:
Applogies for the delay getting back to you, it’s been a busy day. Also, applogies for the state of some of the code, I have been experimenting for a few days to get this working. (Just for reference, I am a senior developer with a wide variety of experience.)
Could you grab a fresh copy? I cleaned up a few things to make it easier for you to see what is going on.
The idea is that coaches need to log in, upload certifications, practice plans, and keep their contact information up-to-date. To that end, I implemented and modified Velo Tutorial: Building Your Own Members Area | Help Center | Wix.com. To track who submits certifications and plans, I need a validated user name, which doesn’t seem to be readily available from wix-users api. Since names, emails, etc. can change, it seems best to normalize the data with a unique index value.
There is beforeInsert hook that created a unique integer Id (in column pk). Since numerics cannot be used as indicies, that number is copied to the text field Title. That was working for a while. It stopped working as some point, but I don’t exactly when. Otherwise I would revert the last change to get it back. The beforeInsert hook is in data.js. This hook is not being called either.
With that said, to get it to the point where the beforeUpdate should fire, do this:
Make yourself a Site Member
Clear out data in CoachInfo collection.
Preview from: COACHES >> Coach list
Click My Info
It will appear nothing happened, but there will be messages in the console log. (beforeInsert should have fired.)
Close Preview
Add a unique index in the collection for Title and pk (e.g.: 1) for your record
Preview from: COACHES >> Coach List
You should see default information
Click the Name column (note name is not updating, unless beforeUpdate fired on your copy)
Change first, last, whatever.
Click submit
Note: the information you changed was updated, fullName was not.
Approved members need to read from this collection, and modify their own data. Since Form Submission only allows Admin to read and edit the data, I’m not sure how that would help.
This is an odd one, thanks for your help getting this straight.
Nothing has happened that isn’t above. It’s frustrating not to be able to use such a basic and critical feature.
As a workaround, I had to modify values on the dataset on every page . That was painful to implement, and it’s a maintainance nightmare. It will only work as the data is being submitted, but the asynchronous nature of those submits requires heavy workarounds.
I’ve spent 3 days on this issue thinking it was me. Wix says no one else has raised this issue. However, I’m starting to feel there is something wrong. I love Wix, but this feature would definitely make life easier.
As you see, the issue was raised a month and a half ago. We missed some important deadlines because of this problem.
Actually, I started with a trouble ticket but they sent me here instead. I purposely did not start with the forums because I have enough software experience to know the problem is not with my code. Not that I write perfect code, but I exhausted every possibility trying to solve the problem myself. Trust me when I say I have a lot of computer experience.
Graphically, Wix is nice. I’m used to working with a few hundred database tables, and it’s database features feel primitive and limiting to me. More like SharePoint Lists or Excel at it’s simplest.
Hi becker2012,
I tried to take a look at your site, but there’s no more logic in data.js
But - there’s still 2 imports in that file: import wixData from ‘wix-data’; import wixUser from ‘wix-user’;
Note that the second import is incorrect, you probably meant ‘wix-users’. I guess that’s why the data.js file failed to load in the backend, thus no hooks were running.
Also, to use the users API in the backend you should use the following import instead:
import wixUsers from ‘wix-users-backend’;
I’ll take a look at those later tonight when I have free time. I had to clean out data.js while developing workarounds since we were trying to meet deadlines and blocked by this. Yisreal made a copy, but I don’t have access to that.
Does wix-user-backend give me access to the validated users name? All of this effort is trying to attach a users name to a record so other users can see who uploaded certain files.
That ID is a GUID. We want to display the person’s name.
For example: a coach will upload a practice plan for all the other coaches to see. Everyone needs to know who uploaded the plan, so we need their name displayed with the plan.
I added a page Testing Hooks and collection TestingHooksCollection . Data.js has the following and nothing else:
export function TestingHooksCollection_beforeInsert(item, context) {
item.hookedField = item.editField; return item;
}
I was experimenting by removing " importwixUserfrom‘wix-user’;" then added it back in, and removed it again. The hook got called once, but I’m not sure exactly when. The hooked field didn’t update on the page, but had when I checked the collection later.
I cannot tweek the existing pages since they work (with workarounds) and are starting to be used.