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
NBP1411NBP1411 

Limiting Number of Times a Record Could be Referenced

Hi all,

My customer is looking to use records as inventory (for lack of a better word) where you could only have a lookup record be only used once (could not use that record twice in two different Opportunities in the specific Lookup field). What is the best way to do this inside Salesforce?

Thanks,
Tom
NRD 4 UNRD 4 U
Hi Tom,

This can be achieved through an apex trigger very easily. Once the opportunity is created or updated you can check for the linked lookup record whether the record is linked with any other opportunity. If so give an error. In this case you have to take care whether the record you are referring to are not duplicate. If so you can filter the record to avoid duplicity.
 
Let me know if you have any other query. And mark is best answer if it helps.
 
Thanks!
NRD