function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LavieLavie 

Enforcing Referential Integrity for Custom Objects

(Newbie alert...)

I want to define a new custom object called "Bug". Conceptually, there would be a one-to-many relationship between Bug and Cases, as a single Bug could be at the root of many different Accounts reporting the same problem.

Presumably, I would need to add a custom field of BugId to the Case object. However, I obviously want to enforce referential Integrity. Does Salesforce or sforece provide a method of enforcing referential integrity automatically? 

My experience with manually enforcing referntial integrity via apllicative code has been dismal...

Any ideas?

TIA

Lavie

adamgadamg
Currently we don't enforce referential integrity automatically, but stayed tuned.

Message Edited by adamg on 02-26-2004 10:54 AM

Fasttrack Internet MarketingFasttrack Internet Marketing

Been staying tune for almost 9 years now :o) Any news?

Jack HarrisonJack Harrison
It still doesn't seem to be automated - for my organisation I have laid out clear rules for API naming conventions etc, to ensure referential integrity across objects. This can't be automated currently (to my knowledge) but at least by documenting a standard protocol it should avoid any issues with naming conventions between admins :) 
Mukesh Kumar 107Mukesh Kumar 107
Salesforce does provide 'Enforcing Referential Data Integrity', but partially. Here is how:

What it can not do:
- When updating the reference ID with incorrect ID thus breaking the Data integrity, Salesforce doesn't have a way to check this. (But, a manual process could be created to identify such integrity problem, a huge task if performed on each relationship.)

What it can do:
- Making relationship mandatory (lookup relationship)
- Enforcing deletion of relationship before Foreigh Record (Parent Record) could be deleted.

These could be tried:
- Since each Object has a unique prefix for Objid, a custom Apex code could check for validation and existence of a valid record.