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
Mr. WMr. W 

Require a Product when Opportunity created

I want to enforce users to "add product" when they create a new opportunity.  

 

--

 

I am only displaying the "save & add product" button however the user can still decide to cancel while filling out the product and the opportunity still saves. I need to be able to not allow the user to create the Opp. without the Product information filled out.  

 

Any help with how I would accompish this would be great.  

prakash_sfdcprakash_sfdc
Try using Validation rules. If that is not helping, write a small "before insert" trigger
Vinit_KumarVinit_Kumar

Validation rule would not work here,You will have to go for a Before insert Trigger to achieve this.

Mr. WMr. W

Hi Vinit, 

 

I'm very new to triggers.  You think you could help me with the code and the test class?

prakash_sfdcprakash_sfdc