+ Start a Discussion
jisaacjisaac 

validation rule to require entry into a custom object based on an opportunity picklist value

Currently we have our opportunity owners enter the fees for an opportunity into what we call revenue bucket fields. We distinguish between the fees for products that we built and products that we resell (third party products).

 

In some opportunities, we are selling more that one Third Party vendor's products and today we cannot identify how much is related to each vendor. We need more insight into that. 

 

So when the opportunity picklist field "Third Party Vendor" displays "Multiple," I want to require that the opportunity owner has to enter something into a custom object that break out the fees by individual third party vendor. Each specific vendor will be a new item in the related list.

 

Can someone help me with the rule (if it can be done)

 

 

fredkafredka

If I understand you correctly, you only plan on making the user enter data in the custom object IF the third party vendor field displays multiple.

 

Let me first throw out a disclaimer that the out of the box product object that sf now has available may work or you but I have not looked at this option...

 

I think you would be better served by creating one custom object to hold all of the products that you sell.  You would include the vendor of the product as one of the fields on your product object.  I would then create a second custom object that is associated with your opportunity where you enter each product that you sell under the opportunity.  On that object, you can have a lookup field to your products.  This will give you access to the vendor of each product using the relationship.  Perhaps you make this object a master detail relationship with the opportunity.  That will allow you to create roll up summary fields on the opportunity to total your products by vendor.  You could create one roll up summary field on the opportunity to total all quotes that are your product and another field that totals all quotes that are another vendors products...

 

I hope that helps...

 

Fred

jisaacjisaac

Thanks Fred,

But this still does not address the issue of making the custom objects required. That is the issue I am looking for assistance on.

 

I have written a validation rule, but it is not working:

 

AND
((ISPICKVAL(Opportunity__r.Third_Party_Vendor__c, "Multiple")),
(ISBLANK(   Name   )
))

 

The NAME field is the Custom Object Name "Specific Third Party Vendor".

 

 

fredkafredka

To address the requirement, something like this (I did not test this):

 

AND(ISPICkVAL(Opportunity__r.Third_Party_Vendor__c, "Multiple"),OR(ISNULL(TEXT( name)),ISPICKVAL(name,"")))

 

 

tantotanto

Hello,

 

Is there a master detail relationship between the custom object and the Opportunity object? If so, you can create a rollup summary field that counts the number of custom object records related to the Opportunity. Then create a validation rule that says if the picklist is set to multiple and the rollup summary equals 0 then throw the error. The issue with this is that a rep would have to create the opportunity, set the picklist to anything but multiple, create the child records, and then go back to the Opportunity and change the picklist to multiple.

 

A better idea would be to leverage Visualforce and Apex. The code could be written so that if an Opportunity is saved with the picklist set to multiple the user is automatically directed to the edit screen of the custom object and enforces that record is saved.