There is a field CreatedById.
I want to throw an error if there are already values with the same CreatedById values.
How can I write such a validation rule?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
Your question is a little ambiguous.
Do you mean one of the following?
1. You want to check other fields on the record for the same value as the CreatedById.
This is pretty straightforward. Your validation rule could look something like this "CreatedById == LastModifiedById". Sub any field for LastModifiedById. You can check multiple fields in one validation rule.
2. You want to see if any other records have the same value for CreatedById. This would not be possible via validation rule. You only have access to the current record(and lookup values). To achieve this you could create a flow or Apex Trigger.