In the edit page for table task_pers, the drop-down selection for persons comes from task_pers_view with link field team_id. Team_id comes from linking task_pers to table task, which has team_id. It would denormalize the table design to repeat the team_id in the task_pers table, but only persons on the team responsible for this task should be in the select list.
So I made a before edit event to get the team_id from the task table, but I can't figure out how to use it to restrict the drop down list. The lookup requires a link field from the current table, task_pers, which doesn't have the link field, since it's in the task table. And I couldn't even get the corrent link field in the WHERE without errors. I tried storing team_id in $_SESSION, but get syntax error if I don't put $_SESSION outside quotes, or inside quotes. Tried setting variable $team_id in event, but it's local to that function.
So do I need to totally generate my own select code? OR copy the team_id from task and worry about updating it when it changes?