1
AND( 
  NOT( OR($User.ProfileId="00e30000000geag", 
          $User.ProfileId="00e50000000vKto",
          $User.ProfileId="00e50000000z2H8")
  ),
  ISPICKVAL(PRIORVALUE( FAI_Status__c ),"DNS") ,
  ISCHANGED( FAI_Status__c ),
  OR(AND(
      ISPICKVAL(priorvalue(Do_Not_Solicit_Reason__c), "Clearing"),
      ISPICKVAL(priorvalue(Do_Not_Solicit_Reason__c), "Legal") )
  )
)

the above validation rule is for users, outside of the profiles listed, that can make a change on a custom picklist field called "FAI Status" when the option is DNS. But those users cannot change the FAI Status from "DNS" when the Custom field called: DNS Reason has the following selections: "Clearing" or "Legal"

the rule is written for both fields DNS and DNS reason but how do i write the rule if the user only changes the DNS reason field from Clearing or Legal?

example:

the record has FAI Status = DNS and DNS reason = Clearing. user leaves FAI status at DNS but wants to change DNS reason to "non-clearing".

How do i write this rule?

Chad

1
  • Tip: Use $Profile.name = "Foo" instead of $User.profileId = "someId" - way more readable
    – cropredy
    Nov 17, 2015 at 1:07

1 Answer 1

1

I would suggest you create 2 seperate Validation Rules for the 2 fields.. this will give you flexibility to change them independently and also to display a proper error message next to these fields

for the FAIStatus field, you can use the current one you have with the slight change of checking the current value (instead of priorvalue) of the reason field

AND( 
  NOT( OR($User.ProfileId="00e30000000geag", 
          $User.ProfileId="00e50000000vKto",
          $User.ProfileId="00e50000000z2H8")
  ),
  ISPICKVAL(PRIORVALUE( FAI_Status__c ),"DNS") ,
  ISCHANGED( FAI_Status__c ),
  OR(
      ISPICKVAL(Do_Not_Solicit_Reason__c, "Clearing"),
      ISPICKVAL(Do_Not_Solicit_Reason__c, "Legal")
  )
)

and then have a similar one for the DNSReason field but check if the reason field got changed when the FAIStatus value is DNS

AND( 
  NOT( OR($User.ProfileId="00e30000000geag", 
          $User.ProfileId="00e50000000vKto",
          $User.ProfileId="00e50000000z2H8")
  ),
  ISPICKVAL(FAI_Status__c ,"DNS") ,
  ISCHANGED( Do_Not_Solicit_Reason__c ),
  OR(
      ISPICKVAL(PRIORVALUE(Do_Not_Solicit_Reason__c), "Clearing"),
      ISPICKVAL(PRIORVALUE(Do_Not_Solicit_Reason__c), "Legal")
  )
)

You must log in to answer this question.

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