WHERE clause for field of the “one” side of a OneToMany relationship
-
Hello,
I struggle with this for some time now.
The forum seems not to have an answer yet.Usually this means it is either a very special and complicated problem OR
it’s so extremely simple that nobody else has a problem with it. ??I have a pod named “event” that has a one-to-many-relationship with another pod named “attendee“.
So I added a multi select relationship field to “event” and a single select relationship field to “attendee”.It all works really well.
When editing an event, the multi select field gives me a “List View input” of attendees assigned to the current event. Nice.
I can reorder them, edit them, remove them and even add completely new attendees. Very nice.BUT:
Above the attendee list I get an search/dropdown element where I can add existing attendees to the event.This list however contains ALL existing attendees. Even those that are already assigned to another event.
I don’t want to re-assign attendees from their event to the event I’m currently editing.
It could be a useful feature but I don’t need it.So the list should only contain attendees that are either NOT assigned to any event or attendees that are already assigned to my current event.
So I thought I would simply limit the attendees in the dropdown by adding some conditions to the custom WHERE clause of the field.
Since the SELECT statement tries to load “attendee” pods at this point, the logical WHERE clause would be “event.ID IS NULL OR event.ID = {???}
”The “
{???}
” part is what I’m struggling with.
It should reference the ID of the event I’m currently editing.
But for some reason I can’t get that reference from the system.I tried to do it with magic tags (
{@ID}
and{@_pod.id}
seemed obvious) but none of them worked.Do you have an idea if it is achievable at all and if yes how it should be done?
- The topic ‘WHERE clause for field of the “one” side of a OneToMany relationship’ is closed to new replies.