I have a type called Event in my database. Event has a previous field, which is an Event too.
Given an Event, I wanted to display that and all the previous events recursively in a repeating group, stopping when an Event has a null previous field.
I tried to do that through a custom event that calls itself, but it’s not possible to call a custom event recursively.
Do you mean that you want to show list of Events, and inside each event in that list, you want to show another list of previous events?
In that case, you can nest repeating groups, which essentially means to place anoter repeating group inside the first cell of the initial repeating group. The source of that nested group can then refer to the current cell’s event to call a list, or to filter a search.
Was that what you. meant, or am I misunderstanding you?
A theory that I haven’t tested, but what if you did:
Do When Condition is True (every time) event, condition being “only when RG’s list of items :count is RG’s list of items’ previous item : count”
Action = Display List > RG’s list of items : plus item RG’s list of items : last item’s previous event
So only when all items in the list have a previous event do you keep adding to the list.
The only thing I can’t confirm without testing is if the “Do When…Every time” event will actually fire after every Display List action, or you may have to use a custom state to help toggle the condition on and off to re-trigger the “Do When… Every Time”
Try it out though. I can test it out tomorrow as well.
Other solutions would be to give events in a family the same IDs or add all child events to list fields of all parents, grandparents, etc.
I have 5 events called A, B, C, D, E. Each of them has a “previous” field.
E’s previous event = D
D’s previous event = C
and so on.
A’s previous event = empty
If I choose C, the repeating group is populated with A, B, C.
If I choose E, the repeating group is populated with A, B, C, D E.
Basically, the repeating group displays all the previous events of a starting event until it finds an event without a previous event (in this case the A event).
I’m writing a test app to show you what I intend to do.
Sadly, the sorting is based on causality: event B follows event A because it depends on A (A’s previous is B).
It might be true that if A causes B then it should have happened earlier than B.
Ah, tricky. And can an event be a “Previous” to many other events?
If not, then you could add a “sort order” number field to the Event type. Setting the Previous Event would let you set the sort order and then you can sequence something like A = 1, C = 2, B = 3