This topic is locked
[SOLVED]

How to allow admin to add records that will be owned by other users?

3/1/2025 12:30:11 PM
PHPRunner General questions
W
wfcentral author

In this scenario where you have a table called "rosters" and a table called "students".

You have users that login as instructors, create rosters and assign students to the rosters (as child records). The permissions in PHPRunner are set that instructors can only see and edit their own records. Both tables rosters and students have a field called "instructor_ID" in them.

The issue is that I have admin users who help the instructors. These admins have "full admin access" to the tables through PHPRunner dynamic permissions. When an admin user adds a student to an instructors roster the "instructor_ID" is populated with the ADMIN (logged in user) ID number. This makes it so the instructors cannot see those students added by the Admin user.

I need a way for an Admin to add a student record and it take on the instructor ID.

I tried linking the roster to students on TWO sets of fields
roster_ID.id = students.roster_ID
roster_ID.instructor_ID = students.instructor_ID

Still when admin adds a student it populates the instructor_ID with the admins ID number.

C
Chris Whitehead 3/1/2025

Create a new page for the admin only to add students and make the instructor_id a lookup in designer, that way the admin can select the instructor when adding that leaves the standard instructor page staying the same.

W
wfcentral author 3/1/2025

thanks - I may have to do that... it was something I thought of. They have about 1,000 instructors. So, the only way to pull that off would be to use an ajax dropdown where they just start typing in the instructors name. This all seems a bit like the wrong way of going about it though. I was hoping to find some way of doing it using events. Since you are adding a student to a roster and the roster know what the instructors ID is, it would seem you could write an event to get the parent field data and use it to update the student record.

W
wfcentral author 3/2/2025

In case someone else is looking for an answer - I found it. I did a combination of what Chris mentioned AND what I already had setup. With the tables linked together on two fields I created a new page for admin only. I set the permissions for that page to "can see and edit all records" and then I made this page only visible to admin users. The result is that when they add a student record from the roster screen it correctly assigns the parent instructor ID to the student record. So, I did not need to have a lookup and make them pick the instructor each time.