0

I had two objects quote1__c and quote_line_item__c with lookup relationship.

I am writing this validation rule at quote line item level

Quote_owner__c is formula field which get the quote1__r.Lastname from quote

if((Quote1__r.CreatedBy.LastName='Chirina'|| 
    Quote1__r.CreatedBy.LastName='MILLIEZ'), 
   (AND(ISNEW(), 
        (Quote_owner__c=='Chirina'|| 
         Quote_owner__c=='MILLIEZ'))),
   false)

when a new quote_line_item record is created it has to check the Quote_owner__c name - if it is "chirana" or "millez" it has to save the record, otherwise it has to throw error.

3
  • 1
    I guess you are not even being able to save it, your IF function needs to return two possible values, true and false (or viceversa) IF( AND (somevalue='hey',value2='you'),true,false). You formula is not doing this.
    – PepeFloyd
    Jun 5, 2014 at 8:13
  • any other way you can suggest .in true condition it has to satisfy the expression
    – Teja
    Jun 5, 2014 at 8:23
  • You can do it the other way around as well. IF(condition, false,true)
    – PepeFloyd
    Jun 5, 2014 at 8:42

1 Answer 1

1

Validation rules should return true on the error condition. Check out these helpful examples. As such, you shouldn't need an IF statement here. Think about this as "when do I want this to throw an error?" The corresponding statement you should be saying is "We should throw an error if we are creating a Quote_Line_Item and it was created by someone who is not Chrinia or MILLIEZ. This should work for you:

AND(ISNEW(),
    OR(NOT(Quote1__r.CreatedBy.LastName='Chirina'),
       NOT(Quote1__r.CreatedBy.LastName='MILLIEZ')))

You must log in to answer this question.

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