# Configuring Quantity Tracking

Quantity Tracking enables Lab Analysts to track the quantity of product that needs to be stored and how much needs to be pulled from storage at each *Timepoint* throughout the duration of a study. In order to configure this feature for use, an Admin must complete the following steps:



1. Navigate to **Admin > Configuration > Objects > Lab Sample Definition** and select the **Fields** tab.
2. Select **Storage Condition**.
3. Click **Edit**.
4. In the **Options** section, check the **Display in default lists and hovercards** box.
5. Click **Save**.
6. Return to **Admin > Configuration > Objects > Lab Sample Definition > Fields** and select **Storage Orientation**. Repeat steps 3-5 for this field. This ensures that these values are displayed on the *Collect Action* record (related to *Spec Data*) when a user hovers over the *Sample Definition* field.
7. Navigate to **Admin > Configuration > Object Lifecycles** and make modifications to the following lifecycles:
    1. **Spec Data**: 
        1. On the **Effective** state, configure an <a href="/en/gr/59885/#entry-actions">Entry Action</a> to trigger the *Update Inventory* action. Make sure that this action is only configured for *Spec Data* object type *Stability Study Spec Data*. The system allows configuration for other object types, but the action cannot execute for those types and will fail silently without error.
    2. **Lab Study**: 
        2. On the **Completed** state, add an Entry Action to set `completed__v=true`
        3. On the **New** state, add an Entry Action to set `completed__v=true`
        4. On the **Timepoints Complete** state, add an Entry Action to set `completed__v=true`
    3. **Lab Study Timepoint**: 
        5. On the **Cancelled** state, add an Entry Action to set `cancelled__v=true`
        6. <a href="/en/gr/51700/#how-to-edit-or-delete-event-actions">Remove</a> the **Create Record** event action.
    4. **Lab Sample**: On the **Unreceived** state, ensure that the *Pull Sample* action uses the standard workflow `lab_sample_pull__v`
8. Navigate to **Admin > Configuration > Objects > Lab Study** and complete the following steps:
    5. On the **Actions** tab:
        1. <a href="/en/gr/43127/">Set the **Refresh Inventory** action to **Active.**</a>
    6. On the **Layouts** tab:
        1. Add the **Inventory Summary** <a href="/en/gr/26387/#add-edit-move-sections">Related Object Section</a> and select the **Prevent Record Creation** *Creation Option*.
        2. Add the **Inventory** <a href="/en/gr/26387/#add-edit-move-sections">Related Object Section</a> and select the **Prevent Record Creation** *Creation Option*.
9. <a href="/en/gr/32857/#assign">Assign</a> the following fields to the **Stability** object type on the **Lab Sample** object:
    1. Sample Definition
    2. Sample Plan
    3. Spec Execution
    4.  Unit of Measure
    5.  Planned Quantity
    6.  Study
    7.  Study Timepoint
    8.  Time Stored
    9.  Time Stored Units
    10. Inventory Record
    11. Sample Instructions
    12. Label Definition
    13. Label Quantity
    14. Quantity
    15. Due Date
    16. Manually Added
    17. Mode of Creation
    18. Spec Data
    19. Spec Data Sample Action
10. Navigate to **Objects > Spec Data** and complete the following steps: 
    1.  On the **Actions** tab:
        1.  <a href="/en/gr/43127/">Set the **Create Collect Sample Actions** action to **Active.**</a>
11. Navigate to **Object Lifecycles > Spec Data Lifecycle** and complete the following steps:
    1.  On the **Effective** state, add the following <a href="/en/gr/59885/#entry-actions">Entry Action</a>: If Spec Data Type equals Stability, Update Inventory.
    2.  On the **Draft** state, add the **Create Collect Sample Actions** <a href="/en/gr/59885/#user-actions">User Action</a>.
12. Return to **Objects > Spec Data** and complete the following steps:
    1.  On the **Layouts** tab:
        1.  Select **Stability Spec Data Detail Page** and <a href="/en/gr/26387/#related-objects">add a section</a> for *Spec Data Sample Action* using the following VQL criteria: `object_type__vr.api_name__v = 'spec_data_collect_action__v' (Apply on creation=true)`
13. Navigate to **Objects > Lab Study > Actions** and <a href="/en/gr/43127/">set the **Activate Refresh Inventory** action to **Active.**</a>
14. Navigate to **Object Lifecycles > Lab Study** and add *Activate Refresh Inventory* as a <a href="/en/gr/59885/#user-actions">User Action</a> to the **New** and **In Progress** states.
15. <a href="/en/gr/26387/#how-to-add-object-fields">Add</a> **Use Quantity Tracking** and **Use Draft Spec Data** to the page layouts for the *Lab Study Design* and *Lab Study* objects.
16. Add a <a href="/en/gr/51632/">Layout Rule</a> to hide the *Inventory* and *Inventory Summaries* fields if the *Use Quantity Tracking* field equals *false*.