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
jhonnajhonna 

Custom Object - Composite Primary Key

I wanted to know if Having a composite primary key was possible with Custom objects?


In my RASolution__c object,  I wanted to have Composite Primary Key  of Case number and Solution ID.  When Case number is of "lookup" type to Case Table.


I want to make sure the solution_id  of RASolution obect for each CASE remains unique.


In my custom RASolution object, I cannot make the Solution_id unique as multiple cases might have the same solution.

 

Thanks.

JH

Ispita_NavatarIspita_Navatar

I think in your scenario as you have pointed out correctly masking the solution id unique is not plausible as many cases may have a particular solution, but what you want to implement is that a particular case can be linked with only one solution at all times. This can be easily implemented using a trigger , where you run a query in your custom object if "Select 1d from custom object where solutionid != Current solutionid" if this is greater than 1 then you can raise an error and say that a particular Case can always have only 1 solution.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

 

qsdunnqsdunn

I may be failing to understand the problem here but why doesn't Case have a custom look-up field of type RASolution.

 

Then each Case has at most one RASolution and one RASolution can be referred to by multiple Cases. Which seems to be what you're wanting...