I need to create a validation rule on two lookup fields on same custom object so that only two users A and B can change values on that field,rest other users cannot change values.

Kindly help!!

I tried the syntax i.e .AND ( ISCHANGED( Owner_Proposal__c ), $User.Username ="andrew@abc.com"<> "Owner_Proposal__c ", $User.Username="elan@dfc.com"<> "Owner_Proposal__c ") but I get a syntax error.

Please let me know the reason for syntax error.

Need your help!!


Use the below formula to create your validation rule.

AND( ISCHANGED (Owner_Proposal__c ) , OR( (LastModifiedBy.Username <> 'andrew@abc.com') , (LastModifiedBy.Username <> 'elan@dfc.com')) )

Hope this helps.


| improve this answer | |
  • Thanks a lot Ruchika. It worked perfectly. Actually I am new to salesforce.Can you provide me some links so that I can learn how to use formulaes. – kunal gupta Aug 13 '15 at 8:58
  • If I need to add another field owner close how can I add in the existing syntax – kunal gupta Aug 13 '15 at 9:39
  • what validation exactly you want to put on the owner close ? Can you explain bit briefly what you want to do in it ? – Ruchi Aug 13 '15 at 10:12
  • Hi Ruchika,I want to add both fields under same syntax. ie. I want to add owner_close_c field under same syntax .Is it possible or new need to create a workflow inorder to use both syntax in one formulae – kunal gupta Aug 13 '15 at 10:15
  • Try doing this: AND( OR(ISCHANGED (Owner_Proposal__c ) , ISCHANGED (owner_close_c) ), OR( (LastModifiedBy.Username <> 'andrew@abc.com') , (LastModifiedBy.Username <> 'elan@dfc.com')) ) – Ruchi Aug 13 '15 at 10:22

Try this:

AND ( ISCHANGED(Owner_Proposal__c), 
          $User.Username <> "andrew@abc.com",
          $User.Username <> "elan@dfc.com"

If you read it from beginning, that mean - if some field is changed and user name is not equal to one or not equal to another one - show error.

In your formula in can not understand what is this:

$User.Username ="andrew@abc.com"<> "Owner_Proposal__c "

Because result of first part is boolean (true or false, $User.Username is equal or not equal to "andrew@abc.com"), as well as last argument is string type. It can not compare boolean result with string, so it shows syntax error.

Here you can find examples of validation rules: https://help.salesforce.com/HTViewHelpDoc?id=fields_useful_field_validation_formulas.htm&language=en_US

| improve this answer | |

why you want validation rule you set field level security where those 2 user profile can only have access to the field not other. Setup > Build> create> open the object and click on the filed you want to hide from other users> click on set-field-level security > and select the profile.

| improve this answer | |
  • Hi Anu, The other users can edit the values but they cannot change the values,other users while entering values after saving cannot change values while these two users can change values – kunal gupta Aug 13 '15 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.