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
KPDKPD 

Opportunity and error message

Hi all.Can somone help me in writing triggers for below two scenarios.
1.Create opportunity if account is created.  If Existing account is updated, then if opportunities under that account are not available then create one opportunity.

2.On a custom object check if the duplicate record is getting created on the basis of name. If duplicate record is getting created then user should get an error message "Record with same name already exist".
Shalom RubdiShalom Rubdi
GDP - you can accomplish both of these without triggers
  1. To create an opportunity when an account is created or updated, you can use process builder:
  2. You can use duplicate management with custom objects:
KPDKPD
Tks for the reply.
As I am new to coding trying to learn how to implement through triggers for the above scenarios.Can u help me out.
 
Shalom RubdiShalom Rubdi
If you are trying to learn coding in Salesforce, consider going through the exercises on Trailhead (http://trailhead.salesforce.com); it is a free tool which you can use for self-guided training.  

Best of luck!