AnsweredAssumed Answered

Creating links automatically for related portal records

Question asked by BarryIrvine on Sep 22, 2011
Latest reply on Oct 4, 2011 by philmodjunk


Creating links automatically for related portal records



I'm trying to do something with a portal that I think should be quite easy but can't for the life of me work out how to do it.

I have a table called Donor. A donor can either be a Person or an Organisation. So I have created two other entities with primary keys organisation_id and person_id. I'm trying to link these to Donor so that if the is_organisation checkbox is selected only the portal to Organisation is active and if it isn't only the portal to Person is active.

The Person table then contains fields such as first_name, last_name whilst Organisation contains organisation_name.

I've created the fields organisation_id and person_id in Donor as well and created the relationship so that Donor.organisation_id = Organisation.organisation_id etc. I've also enabled Allow creation of records in this table via this relationship on the Person and Organisation side. Normally I'd link Organisation and Person back to donor_id but I may want to use Person and Organisation for other entities in the future.

When I'm in the Donor layout however I can't save any modifications to the Organisation because the organisation_id has not yet been set. I suspect that I need some kind of Script trigger after editing the organisation_name that creates a new record in Organisation and updates the organisation_id in Donor with the correct value. Ideally, I'd also like to do a search on Organisation to see if organisation_name already exists; if it does use this record otherwise create a new record.

How do I go about this?

Thanks in advance,