You need to sign in to do that
Don't have an account?
GTE
Related Object Required
Hello
I have a "Main Object" (Sales Opportunity) and a "Related" object (Product).
Is there a way to setup my main object so that if "Sales Opportunity" status is set to "Prepare Quotation" the object must have a Product related to it?
Thanks
Sales Opportunity should have a lookup field for Product. And on the Sales Opportunity status field do a validation rule which checks if the value of picklist is "Prepare Quotation"and the then the lookup field is"Blank", throw error.
Thanks. This will do if I have at least 1 product. How about if I must require at least "X" product to be related? Can I have something that counts the number of products related and then work the validation rule from there?
Did it work?
Let me explain a bit more. Imagine we sell luxury cars. So for every sales oportunity we need to incluide at least a few products (car model, leather seats, hifi sound system, etc). So I will always need to add more than one product.
If it were just the one product, your idea would do. But for several I need to go and look how many product items are liked to this Sales Oportunity and then count them up.
Thanks
I understood that, so what is the issue?
As said earlier, create a rollup summary field on the Sales Opportunity which basically does store count of related records of "product"
In the validation rule, when ever you change status to the "Request Quote" , do a check for the count and see if it is > 0. If it is then you are fine, else throw error.
Job Application can have multiple reviews, so it is 1 to many relation. There is a status field of picklist which has values "Hired", rejected, ...so on so forth. I created a roll up summary field called "Count of Reviews" which counts how many related child records of review exist. I wrote a validation rule
AND(Number_of_Reviews__c = 0, ISPICKVAL( Status__c , 'Hired') )
What this does is, it checks if the picklist value is "Hired" and the number of reviews is 0, then it throws error saying, you have to have atleast 1 review before you can Hire.
Thanks. This looks pretty much what I need. However, I already have my Oporunity object with a large number of records and not all of them have "products" linked to them, so I cannot creat the Master-Detail relationship.
I there a way around the loop? If i relate at least one "product" record to each Oportunity will I be able to do it?
Not sure what you are saying. You do not need Master Detail relation here. You have a related list, that means you have created lookup relation and that is what is needed.
The solution given works for you, as long as you will add a rollup summary field and create validation rule based on change in picklist value on status
Thanks.
I need a Master - Detail relationship field in my object to create a Rollup field
You already must be having a lookup field on the Product which is linked to Sales Opportunity. That is what you will use.
My bad, my mistake, really appologize for this. Yes the mAster Detail is needed for roll up field. I created the objects long ago and I run all my test on that, and I really missed checking that I had created that relation.
Let me think.
http://boards.developerforce.com/t5/Apex-Code-Development/Rollup-summary-Count-Lookup-Relationship/td-p/429327