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
MMA_FORCEMMA_FORCE 

Can I link a button to a trigger?

I created a trigger that would not let an user create a record if a record exist for that child object.

But Can I link it to a new button. So when the user clicks new, it will fire the trigger off to check if a record is created and not let the user create another record?

Thanks

MMA

Best Answer chosen by Admin (Salesforce Developers) 
jhenningjhenning

If the trigger is set as 'before insert', it will always fire. You don't need to link it to a specific button. All attempts to insert a record will fire the trigger. Use the addError method to cancel the insert if a duplicate row is found: