Multiple relationships via a portal
I seem to be struggling again with my relationships via a portal.
I have a Donor entity who can make multiple Donations. A Donation is always linked to a Campaign/Event.
Donation is linked to Donor with donor_id and Event is linked to Donation with event_id.
On my Donor layout I have a portal to Donation which displays 2 Donations on screen and the rest can be accessed using the scrollbar.
I'm struggling to set the value of event_id in the correct Donation record. It seems to only update the first Donation record linked to the Donor.
This is what I did:
I created a Global field called gEventName in the Donation table (I didn't particularly want this to be global but I couldn't get the find to work otherwise).
After setting the value of gEventName using the drop-down list, I fire off a setEvent script onObjectModify:
if [Donation::gEventName ≠ ""]
Go to Layout ["Event" (Event) ]
Enter Find Mode 
Set Field [ Event::event_name; Donation::gEventName]
Perform Find 
Set Variable [$EventId; Value:Event::event_id]
Go to Layout[original layout] #I've also tried going to the Donation layout here too
Set Field [Donation::event_id; $EventId ]
Set Field [Donation::gEventName] #Clear the global variable after the find
It only updates the event_id/event_name in the first Donation record in the portal - even if I perform the find in the second record.
Here is a screenshot that may help understand the issue:
Actually I seem to have fixed it myself.
I added a Set Variable [$row; Value:Get (ActivePortalRowNumber)] at the top of the script and then Go to Portal Row [Select; No dialog; $row] before updating Donation::event_id.