---
schema_version: "1"
id: 7d10691f4265caa606a129c426f28053be8d6689ac4e23cc633659a3c97e27b9
title: Set up Automatic Time Sheet Validation
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/aslm_tmsht_set_up_automatic_timesheet_validation.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.aslm_tmsht_set_up_automatic_timesheet_validation.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 02eb1e126172b2c85ebd1896177351d938f8f0df07628e858da583f2f4e1bb31
description: Set up the expression set and records that are used to automatically validate a timesheet submitted by the technician. Automatically create the time sheet entry items and time sheet wage type summaries associated with the submitted timesheet.
products:
  - Industry Solutions
  - Cross Cloud
release: "264"
---
# Set up Automatic Time Sheet Validation

Set up the expression set and records that are used to automatically validate a timesheet submitted by the technician. Automatically create the time sheet entry items and time sheet wage type summaries associated with the submitted timesheet.

### 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: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: All editions of Field Service Plus for Energy and Utilities, and all editions of Asset Service Lifecycle Management</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d43993e60">User
              Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e60 ">To access flow templates</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e60 ">Labor Cost Optimization Admin</td>

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

Use a flow template available in Timesheets and Labor Cost Optimization to automatically validate submitted timesheets. Clone and activate the flow template, create pay type records, expression sets, and service resource cost role records.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:20%">
          <col style="width:20%">
          <col style="width:60%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d43993e96">Flow Template Name</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d43993e99">Usage</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d43993e102">Flow Template Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Flow Template Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e96 ">Process Timesheet</td>

            <td data-label="Usage" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e99 ">Mobile and Desktop</td>

            <td data-label="Flow Template Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e102 ">
              <p>Processes and validates the timesheet.</p>
              <p style="margin-bottom:0;">Used when the Time Sheet status is <strong>submitted</strong>. Triggers the Invocable action (<strong>Validate Time Sheet</strong>)
                to validate the Time Sheet Entries and creates Time Sheet Entry Items and Time Sheet Wage Type Summary.</p>
            </td>

          </tr>
        </tbody>
      </table> <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:25%">
          <col style="width:25%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d43993e150">Invocable Action Name</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d43993e153">Related Flow</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d43993e156">Invocable Action Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Invocable Action Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e150 ">Validate Time Sheet</td>

            <td data-label="Related Flow" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e153 ">Process Timesheet Flow</td>

            <td data-label="Invocable Action Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e156 ">
              <ul>
                <li>Executes Service Resource Cost Rule of type "Timesheet Entry Item Calculation" to create
                  Time Sheet Entry Item records. Rules can have BRE expressions or Apex Classes or both (<code>ServiceResourceCostRule.Rule</code> or <code>ServiceResourceCostRule.ApexClass</code>)
                </li>

                <li>Calculates Wage Type Summary using the created Time Sheet Entry Items
                </li>

                <li>Executes Service Resource Cost Rule of type 'Timesheet Validations' to create
                  Time Sheet Validation records. Rules can have BRE expressions or Apex Classes or both (<code>ServiceResourceCostRule.Rule</code> or <code>ServiceResourceCostRule.ApexClass</code>)
                </li>

                <li>Updates the Time Sheet and Time Sheet Entries status to Approval Pending.
                </li>

                <li>In case of validation failure (such as overlaps in time sheet entries and gaps between time sheet entries)
                  <ul>
                    <li>Time Sheet Entry Items and Wage Type Summary are still calculated, and the status of invalid Time Sheet and/or Time Sheet Entry is set to Error.
                    </li>

                    <li>Time Sheet Validation error records are in a related list to Time Sheet and Time Sheet Entry</li>

                  </ul>

                </li>


              </ul>
            </td>

          </tr>

        </tbody>
      </table>

After a timesheet is submitted, the Process Timesheet flow validates the time sheet record with Business Rules Engine. The expression set also validates the service resource cost rule and pay type records associated with time sheet entries.

Use the Service Resource Cost Rule record to define rules to validate time sheets. You can use either an Expression Set or an Apex Class to validate the time sheet. Alternatively, you can build an Apex Class to provide data to the Expression Set, which then validates the time sheet. To do this, enter the API names of the Apex Class and the Expression Set in the Service Resource Cost Rule record.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:66.66666666666666%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d43993e234">Expression Set Template</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d43993e237">BRE Expression Set Description</th>
          </tr>
        </thead>
        <tbody>

          <tr class="">
            <td data-label="Expression Set Template" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e234 ">Timesheet Entry Item Computation Rule</td>

            <td data-label="BRE Expression Set Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d43993e237 ">
              <p style="margin-bottom:0;">This rule is used to create Time Sheet Entry Item records for the Time Sheet Entries.
                It uses Service Resource's Operating Hours Timeslots to calculate the PayTypes.
                If the service resource doesn't have the operating hours (Service Territory Member's
                Operating Hours is null), then it considers the Service Territory's operating hours. </p>
            </td>

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

To configure a custom validation rule that is executed when a timesheet is submitted, create a Service Resource Cost Rule record with type Timesheet Validations.

1. Clone the flow builder templates available with Timesheets and Labor Cost Optimization. You must create at least one flow from each of the templates listed earlier.
    1. From Setup, find and select **Flows** under Process Automation.
    2. Click the flow template that you want to clone. For example, click **Process Approved TimeSheet**.
    3. Click **Save As** on the header of the flow builder and enter a flow label and a flow API name.
    4. Save your changes
    5. To activate the flow, click **Activate**.
2. Create pay type records for Regular Time, Over Time, Double Time, Vacation Pay, and set their associated Wage Types.
    
    Pay type records are used in the Process Timesheet flow to automatically associate labor costs to a timesheet entry.
    
    1. From the App Launcher, find and select **Pay Types** .
    2. Click **New**.
    3. Set the Effective Start Date to any date in the past.
    4. Select **Active**.
    5. Enter a name. For example, enter Regular Time.
    6. Select a wage type. For example, Regular Type.
    7. Save your changes.
    8. Repeat these steps until you create all available pay type records.
3. Create an expression set from Timesheet Entry Item Computation Rule template.
    1. From the App Launcher, find and select **Expression Set Templates**.
    2. Click **Timesheet Entry Item Computation Rule template**.
    3. In Expression Set Properties, in Rank, enter 1.
        
        When more than one enabled version matches an expression set call, and the datetime periods overlap, the version with the highest rank is chosen. For example, if two enabled versions have rank values set to 1 and 2, the version with rank 2 is chosen.
    4. Save and activate the expression set.
4. Create an expression set from Timesheet Vehicle Validation Rule template.
    1. From the App Launcher, find and select **Expression Set Templates**.
    2. Click **Timesheet Vehicle Validation Rule template**.
    3. In Expression Set Properties, in Rank, enter 1.
        
        When more than one enabled version matches an expression set call, and the datetime periods overlap, the version with the highest rank is chosen. For example, if two enabled versions have rank values set to 1 and 2, the version with rank 2 is chosen.
    4. Save and activate the expression set.
5. To use either expression sets or Apex classes to validate time sheet records, set the Rule field in the service resource cost rule page as an optional field.
    1. From the object management settings for Service Resource Cost Rule, go to **Page Layout**.
    2. Under Service Resource Cost Rule Detail, for the Rule field, click **Properties**.
    3. To set Rule as an optional field, deselect **Required** .
    4. Save your changes.
6. Create a service resource cost rule record.
    
    The service resource cost rule record is used in the Process Timesheet flow to automatically associate pay types with timesheet entry items.
    
    1. From the App Launcher, find and select **Service Resource Cost Rule**.
    2. Click **New**.
    3. Enter a name, for example, Timesheet Entry Item Computation.
    4. In Rule, enter the API name of the expression set or the Apex class that you want to use to compute time sheet entry items for the time sheet. For example, TimesheetEntryItemComputationRule.
    5. To prepare the data for the Business Rules Engine Expression Set, enter an either an Apex Class or a Standard Apex Class. For example, select `ifstmsht.TimeSheetEntryItemRuleDataHandler` for Standard Apex Class.
    6. Select a labor union.
    7. Activate the rule.
    8. For Type, select **Timesheet Entry Item Calculation**, and save your changes.
7. Create a service resource cost rule record.
    
    The service resource cost rule record is used in the Process Timesheet flow to create Time Sheet Validation Errors if necessary for labor union compliance.
    
    1. From the App Launcher, find and select **Service Resource Cost Rule**.
    2. Click **New**.
    3. Enter a name, for example, Vehicle Validation Rule.
    4. In Rule, enter the API name of the expression set or the Apex class that you want to use to compute time sheet entry items for the time sheet. For example, TimesheetVehicleValidationRule.
    5. Select a labor union.
    6. Activate the rule.
    7. For Type, select **Timesheet Validations**, and save your changes.