0

I am working on a validation rule where Current user cannot be Record creator /Con Owner. Here I am storing current user in a field called requester and it should no be same as either the record(referring to the object gc in which I am creating the validation) creator or the con owner. Here in gc I have given con as a master detail field.

My validation rule:

OR (Requester__c = Con__r.OwnerId,
Requester__c= $User.Id)

Gave record creator as $User.Id

Is it the right way?

6
  • For creator you have to check with CreatedBy.Id or Createdbyid. $User.Id will give you the current user id who is editing it Commented Aug 26, 2022 at 12:23
  • @SaiPraveenKakkirala Actually that is fixed instead of user id I gave requested by id which was the needed condition. So new formula is OR (Requester__c = Con__r.OwnerId, Requester__c= $Requested_by.Id).
    – user121495
    Commented Aug 26, 2022 at 13:09
  • @SaiPraveenKakkirala I have to add an extra condition such that if the requested by or requester field is null then the validation shouldnt occur. How it is possible.
    – user121495
    Commented Aug 26, 2022 at 13:10
  • As you said that the validation should not fire for Requester__c is null you have to add AND condition for it as below. AND(NOT(ISBLANK(Requester__c)),NOT(ISBLANK(Requested_by__c)), OR (Requester__c = Con__r.OwnerId, Requester__c= $Requested_by.Id) ) Commented Aug 26, 2022 at 13:12
  • @SaiPraveenKakkirala Thanks it worked.
    – user121495
    Commented Aug 26, 2022 at 15:00

1 Answer 1

1

For creator you have to check with CreatedBy.Id or Createdbyid.

$User.Id will give you the current user id who is editing it .

And also as mentioned in my comment if you want to bypass this validation rule if Requester__c is blank then you have to use AND() condition. So your validation rule will be as below.

AND(NOT(ISBLANK(Requester__c)),
    NOT(ISBLANK(Requested_by__c)), 
    OR (Requester__c = Con__r.OwnerId, 
        Requester__c= $Requested_by.Id) )

You must log in to answer this question.

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