---
schema_version: "1"
id: 26772402a4834f6dd39f30e29141700cde99343f6bd07377e32b53579bdd37bb
title: Sample User, Role, and Profile Validation Rules
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/fields_useful_validation_formulas_userroleprofile.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.fields_useful_validation_formulas_userroleprofile.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 22431c1b4adab12d79c38e0e8a94be2260b8eb5c87ca93911b75b71e4004cb02
description: Examples on how to validate custom user, role, and profile fields.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Sample User, Role, and Profile Validation Rules

Examples on how to validate custom user, role, and profile fields.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: both Salesforce Classic and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Contact Manager</strong>, <strong>Group</strong>, <strong>Professional</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, <strong>Developer</strong>, and <strong>Database.com</strong> Editions</td></tr></tbody></table>

For more information on any of the formula functions used in these examples, see [Formula Operators and Functions](https://help.salesforce.com/s/articleView?id=platform.customize_functions.htm&release=264.0.0&type=5 "Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula, such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.").

## Discount Percent Does Not Exceed Role-Based Limit

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e102">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e105">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e102 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e105 ">Validates that a custom field on opportunities called <samp class="parmname">Discount
                Percent</samp> does not exceed a maximum value that varies depending
              on the user’s role. The default maximum is 15%.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e102 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e105 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>Discount_Percent__c &gt; VLOOKUP(
    $ObjectType.Role_Limits__c.Fields.Limit__c,
    $ObjectType.Role_Limits__c.Fields.Name, 
    $UserRole.Name
)</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e102 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e105 ">Discount (%) exceeds limit allowed for your role.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e102 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e105 ">
              <samp class="parmname">Discount Percent</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Expense Amount Does Not Exceed User's Max Allowed Expense

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e190">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e193">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e190 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e193 ">Validates a custom field called <samp class="parmname">Expense Amount</samp>
              against a custom user field called <samp class="parmname">Max Allowed
                Expense</samp>.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e190 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e193 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>Expense_Amount__c &gt; $User.Max_Allowed_Expense__c</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e190 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e193 ">Amount cannot exceed your maximum allowed expense.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e190 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e193 ">
              <samp class="parmname">Expense Amount</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Only Record Owner Can Change Field

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e281">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e284">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e281 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e284 ">Ensures that only the record owner can make changes to a custom field
              called <samp class="parmname">Personal Goal</samp>.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e281 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e284 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>AND(
   ISCHANGED( Personal_Goal__c ),
   Owner &lt;&gt; $User.Id 
)
</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e281 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e284 ">Only record owner can change Personal Goal.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e281 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e284 ">
              <samp class="parmname">Personal Goal</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Only Record Owner or Administrator Can Change Field

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e370">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e373">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e370 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e373 ">Ensures that a user can make changes to a custom field called
              <samp class="parmname">Personal Goal</samp> only if the user is the record owner
              or has a custom profile of “Custom: System Admin.”
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e370 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e373 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>AND(
    ISCHANGED( Personal_Goal__c ), 
    Owner &lt;&gt; $User.Id, 
    $Profile.Name &lt;&gt; "Custom: System Admin" 
)</code></pre>
              <p style="margin-bottom:0;">$Profile
                merge fields are only available in Enterprise, Unlimited, Performance,
                and Developer Editions.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e370 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e373 ">Only record owner or administrator can change Personal Goal.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e370 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e373 ">
              <samp class="parmname">Personal Goal</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Opportunity Close Date Can Only Be Back-Dated by Administrator

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e461">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d204682e464">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e461 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e464 ">Validates that the <samp class="parmname">Close Date</samp> of an opportunity
              does not fall prior to the current month, except for users who have a custom
              profile called “Custom: System Admin.”</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e461 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e464 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>AND(
  OR (
     ISNEW(), 
     ISCHANGED( CloseDate )), 
  CloseDate &lt; DATE( YEAR(TODAY()), MONTH(TODAY()), 1),
   $Profile.Name &lt;&gt; "Custom: System Admin"
)
</code></pre>
              <p style="margin-bottom:0;">$Profile merge fields are only available in Enterprise,
                Unlimited, Performance, and Developer Editions.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e461 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e464 ">Close Date cannot be prior to current month.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e461 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d204682e464 ">
              <samp class="parmname">Close Date</samp>
            </td>

          </tr>
        </tbody>
      </table>