Hello everyone,
I need to automatically assign the logged-in user to a filled form
(in order to automatically link them on a dynamic page)
I have 2 forms :
1st form : University informations : University HR employee creates a university profile :
it creates a dynamic university profile page that will be visible for everyone
2nd form : Teacher job offer : The university can fill this form to create a job offer to find teachers.
This form can be filled only by members (university HR that already created a university profile)
it creates an offer that will be visible on the university profile page.
My issue : I need that when the Teacher job offer form is filled by the university employee, the logged-in user is automatically assigned to this form data.
My suggestions :
I tried to create a reference filed in the Job offers database linked the University database.
but it can’t be filled automatically. I have to do it manually or ask the university to identify itself in the Job offer form. (I don’t want it - too risky if a university assigns an offer to another university)
Maybe hooks can help - I’m bad at coding, I tried this but it didn’t work :
import wixData from'wix-data';
import wixUsersBackend from 'wix-users-backend';
let user = wixUsersBackend.currentUser;
let userId = user.id;
let universityId = wixData.get("universityProfiles", "universityDatabaseMainField");
export function jobOfferForm_beforeInsert(item, context) {
item.universityReferenceField = UniversityId;
return item;
}
Can someone help me ?
Thanks a lot !!!