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
jisaacjisaac 

Making a Custom Object required on an opportunity - can it be done?

Has anyone built something to require the user add an item into a custom object in order to save an opportunity?

Best Answer chosen by Admin (Salesforce Developers) 
Steve :-/Steve :-/

Hi Jane,

 

If the Custom Object has a Master-Detail(Child) relationship to the Opportunity, you can create a Roll-Up Summary field on the Opportunity that returns the COUNT of the Custom Child Object records.  Then you can write a VR that will throw an error if certain conditions on the Opportunity are TRUE and the Roll-Up Summary field is < 1.

All Answers

Steve :-/Steve :-/

Hi Jane,

 

If the Custom Object has a Master-Detail(Child) relationship to the Opportunity, you can create a Roll-Up Summary field on the Opportunity that returns the COUNT of the Custom Child Object records.  Then you can write a VR that will throw an error if certain conditions on the Opportunity are TRUE and the Roll-Up Summary field is < 1.

This was selected as the best answer
jisaacjisaac

Thanks Steve - I knew there had to be something! That works - thanks again.

MsweeneyMsweeney

I've just set this up with a custom object under opportunities but have noticed a problem. If you go to create or edit an opportunity the custom objects don't appear until after you have saved what you have done. This means that with the current validation rule in place I can't create an opportunity because I need to add information to the custom object first.

 

Any ideas?

Steve :-/Steve :-/

That's just something that you have to live with in SFDC, it's no different than creating an Activity, Contact Role, Product, etc. that are related to the Opportunity.  You can't have 2 related records open for editing at the same time.

 

Can you post the code for your Validation Rule?

MsweeneyMsweeney

I thought that would be the case. The formula was just:

 

Summary_of_Greenlight_Staff_Role__c  < 1

 

The custom object is used to show the staff associated with the opportunity.

 

The only thing I can think of is to create a workflow that sends the opportunity owner a reminder after they have created an opportunity to add staff to the custom object.