# Automate Time Sheet Creation, Capture Omni Status Change, and Calculate Shrinkage

Set up basic time sheet automation. Log agents' Omni-Channel status changes throughout the day and use that information to calculate the shrinkage percentage within a shift.

- **Ease of Implementation:** Easy
- **Estimated Time to Implement:** 60 minutes

## Prerequisites

This example requires Omni Channel and Workforce Engagement to be turned on.

## Step 1: Create Custom Fields on the Time Sheet Object

Create custom fields on the Time Sheet object in Salesforce to correspond to the data that you use to calculate shrinkage.

1. From Setup, select **Object Manager**.

2. In the Quick Find box, enter `Time Sheet`, and then select the **Time Sheet** object.

3. Select **Fields & Relationships** from the left pane.

4. To create a field, select **New**.

5. To create a custom field to hold the data, follow the steps. To learn more about creating custom fields, see [Create Custom Fields](https://help.salesforce.com/articleView?id=adding_fields.htm).

6. Create these fields.

   ![time sheet with customized fields](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/custom_fields_on_time_sheet.png)

7. Make sure to add these fields to the layout for testing and deployment.

## Step 2: Create Custom Fields on the Time Sheet Entry Object

Create custom fields on the Time Sheet object in Salesforce to correspond to the data that you use to calculate shrinkage.

1. From Setup, at the top of the page, select **Object Manager**.

2. In the Quick Find box, enter `Time Sheet Entry`, and then select the **Time Sheet Entry** object.

3. Select **Fields & Relationships** from the left pane.

4. To create a field, select **New**.

5. To create a custom field to hold the data, follow the steps. To learn more about creating custom fields, see [Create Custom Fields](https://help.salesforce.com/articleView?id=adding_fields.htm).

6. Create these fields.

   ![Time sheet fields for creation](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/time_sheet_entry_fields.png)

7. Make sure to add these fields to the layout for testing and deployment.

## Step 3: Introduce Automation Using Salesforce Flow

Two flows are used to allow agents to clock in, generate a Time Sheet, and capture Omni Channel status changes throughout the day.

1. From Setup, in the Quick Find box, enter `Flows`, and then select **Flows**.

2. To create your first flow, select **New**.

3. For more information, see: [Salesforce Flows](https://help.salesforce.com/s/articleView?id=platform.flow.htm\&type=5)

4. Create a screen flow to place on the home page.

   ![Salesforce flow showing automation](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/home_page_flow\_1.png)

   ![Automation flow with shift times and records](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/home_page_flow\_2.png)

5. Create a record-triggered flow to capture an Omni status change.

   ![Record-triggered flow to capture Omni status](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/omni_status_change_flow\_1.png)

   ![Flow with entries for decisions and status](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/omni_status_change_flow\_2.png)

## Test This Example

1. Clock in using the screen flow.
2. To simulate the changes in agent availability, change Omni statuses between different presences.
3. Verify that time sheet entries are created and shrinkage is calculated.
