0

I want to create a validation rule at "Opportunity" Standard Object to validate the following.

Opp record Type – sample And Stage not equal to ‘Pending Approval’ Product or product code(item number) ends with -22 or -23 or -24

Then you it should give the following error message. When requesting samples for 130 Lumen parts, stage should be pending approval.

Can any one help me out how to get the "product code" field in opportunity object in a validation rule.

I Shall appreciate your help.

7
  • Are you using standard product code or have you created a custom field to capture product code? Commented Dec 4, 2014 at 10:03
  • @AmitBangad:we are use both the standard as well as custom codes.
    – nikkey
    Commented Dec 4, 2014 at 10:13
  • Ive suggested an approach, you can try that out and use the product codes as you want. Commented Dec 4, 2014 at 10:24
  • @AmitBangad:When the user of profile names:'Custom Marketing Users 10K 25K', 'Customer Service User' are creating a record it should throw an error .So how to include them
    – nikkey
    Commented Dec 4, 2014 at 11:38
  • I modified the answer to include this. Commented Dec 4, 2014 at 13:42

1 Answer 1

1

Step1 :
Create a custom field on 'Opportunity Product'
Type - Number (1,0)
Name - "Lumen Part Code Count"

Step2:
Create a Workflow rule on Opportunity Product with Criteria "OR(RIGHT(Product2.ProductCode,3) == '-23',RIGHT(Product2.ProductCode,3) == '-24', RIGHT(Product2.ProductCode,3) == '-25')" and Everytime record is created.
Write a field update that updates "Lumen Part Code Count" to 1 (Formula Value 1)

Step3:
Create a RollUp Summary field on Opportunity.Name - "Lumen Part Code Sum"
Select Count and "Only records meeting certain criteria should be included in the calculation"
Criteria- Lumen Part Code Count = 1

Step 4 :
Write your validation rule with criteria

 AND(
OR(
$Profile.Name = "Custom Sales User",
$Profile.Name = "Custom Marketing Users 10K 25K"
),
NOT(ISPICKVAL(StageName, "Pending Approval")),
RecordTypeId == '18DigitRecordTypeIdofSample',
Lumen_Part_Code_Sum__c > 0
)


Mention your error message there.

Cheers,

2
  • Alternative to this excellent answer would be to make the Opportunity product field a checkbox entitled is_lumen_product__c and have the WF populate it to true. The essence of your solution is you are working around the inability of RSF to use criteria on the detail record that refer to cross object fields (Product2.xxx fields in this use case)
    – cropredy
    Commented Dec 4, 2014 at 18:52
  • @crop1645:Now their is another clause needed to be added as " the 2 profile users should not have an option to change the stage name again (i.e from "pending approval to request submitted,etc").So how can i restrict this"
    – nikkey
    Commented Dec 5, 2014 at 16:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .