**Source URL:** https://lims.veevavault.help/en/gr/1187557/

# Configuring Retains Testing

Retains Testing involves testing *Samples* from a specific production batch that were set aside and stored for later analysis. These *Samples* may be used to investigate future issues such as quality concerns, customer complaints, or regulatory questions. In some cases, such as under Food and Drug Administration Regulation 21 CFR 211.170 in the United States, setting aside samples for Retains Testing may be mandated by law.

You can only configure Retains Testing within a *Batch Release Spec Data*.

## How to Configure Retains Testing

In order to configure retains testing for use, perform the following steps:

1. Set `retain__v` to *Active* on the *Mode of Sample Creation* and *Sample Association Type* picklists.
2. Update the following objects:
    1. *Spec Execution*
        1. Remove the `state__v = 'effective_state__v ` *Spec Data* VQL and move it to the *Object Type* level for the following types:
            1. *Batch Release*
            2. *Stability*
            3. *Prepared Consumable*
        2. Update the `name_prefix__c` field to:

        `If(object_type__vr.api_name__v="quality_control_sample__v", "QCSample",`
        `if(object_type__vr.api_name__v="operational_criteria__v","OpCriteria",`
        `if(object_type__vr.api_name__v="retain_testing__v", "Retain",""))`

    2. *Spec Data*
        3. Default `retains_testing_frequency__v` to `1`
        4. Default Retains Testing Unit to `RecordByUniqueField($quality_unit_of_measure__v, {$name__v:"Years"}, true)`
    3. *Retain Testing Input*
        5. Add the following custom fields:
            4. *Current Location* (`current_location__c`): Lookup from *Release Lab Sample*
            5. *Release Sample Received Date*: Default from *Release Sample*
        6. Create a new object layout with the following layout rules:
            6. Override Next Retain Pull Date 
                `not(override_next_retain_pull_date__v)`
                `Read Only: Next Retain Pull Date`
            7. Location Change
                `new_location__v != current_location__c && not(isBlank(new_location__v))`
                `Required: Quantity Pulled, Unit of Measure`
            8. Unscheduled Pull
                `not(scheduled__v)`
                `Required: Comments, New Location`

3. Make the following changes to Object Types:
    4. *Retain Testing Spec Execution*
        7. Set *Status* to **Active.**
    5. *Release Lab Sample*
        8. Add the following fields to the *Lab Sample Details* section of the object layout:
            9. *Retain Testing*
            10. *Retains Testing Frequency*
            11. *Retains Testing Unit*
        9. Add the following fields to the *Key Dates* section:
            12. *Last Retain Pull Date*
            13. *Next Retain Pull Date*
        10. Add the following layout rule:
                Lab Sample: Retain
                `not(retains_testing__v)`
                `Hide field(s): Planned Quantity, Quantity Stored, Next Retain Pull Date, Last Retain Pull Date, Retains Testing Frequency, Retains Testing Unit`
                `Hide section(s): <any retains-related sections>`
    6. *Retain Lab Sample*
        11. Set *Status* to **Active.**
        12. Create object lifecycle stages. You can mimic the configuration for *Release Lab Samples*.
        13. Create a new object type layout.
    7. *Retain Inventory*
        14. Set *Status* to **Active.**
        15. Create a new object type layout.
    8. *Retain Inventory Summary*
        16. Set *Status* to **Active.**
4. Make the following additions and changes to the Lab Sample object lifecycle:
    9. *Retained* lifecycle state:
        17. User Action(s)
            14. Initiate Retains Testing
        18. Entry Action(s):
            15. `If Retains Testing = Yes && Retains Testing Unit = Years`
                    `Next Retain Pull Date = DateTimeValue(spec_execution__vr.batch_manufacture_date__v + Years(retains_testing_frequency__v))`
            16. `If Retains Testing = Yes && If Retains Testing Unit = Months`
                 `Next Retain Pull Date = DateTimeValue(spec_execution__vr.batch_manufacture_date__v + Months(retains_testing_frequency__v))`
            17. `If Retains Testing = Yes && If Retains Testing Unit = Days`
                    `Next Retain Pull Date = DateTimeValue(spec_execution__vr.batch_manufacture_date__v + Days(retains_testing_frequency__v))`
    10. *Testing Complete* state:
        19. Optional: If Object Type is *Retain Lab Sample*, add a workflow to modify the *Quantity Returned*
    11. *Unreceived* state:
        20. User Action(s):
            18. Update the *Deliver Sample* workflow conditions to include *Retains Testing Spec Execution*
            19. Update the *Receive Sample* workflow conditions to include *Retains Testing Spec Execution*
5. Make the following changes to workflows:
    12. *Lab Sample: Sample Receipt*
        21. Update the *Change state based on Type* step to use the standard `retains_testing__v` field
            20. Change *State* to *Retained* formula: `object_type__vr.api_name__v = 'release_lab_sample__v' && (retains_testing__v = true || (sample_type__v = Picklist.sample_type__v.retains__v || sample_type__v = Picklist.sample_type__v.qc_backup__v))`
            21. Change *State* to *Not Started* formula: `not(object_type__vr.api_name__v = 'release_lab_sample__v' && (retains_testing__v = true || (sample_type__v = Picklist.sample_type__v.retains__v || sample_type__v = Picklist.sample_type__v.qc_backup__v)))`
    13. *Lab Sample: Modify Returned Amount*
        22. In the *Instructions* field, add *Enter the total quantity of this sample that has been returned to storage.*
        23. Add prompts for the *Quantity Returned* and *Unit of Measure* fields.
    14. *Lab Sample: Disposal*
        24. On the *Start* step, add Instruction 2: *Confirm that the sample should be moved to the disposed location and that the remaining Retain Inventory should be disposed.*
        25. Add the following *Start* step rules:
            22. Retain Inventory exists
                    Formula: `retains_testing__v`
                    Hidden: Instruction 1

            23. Retain Inventory does not exist
                1. Formula: `not(retains_testing__v)`
                2. Hidden: Instruction 2
        26. Add an *Action* step to update *Retain Inventory*:
                `If Retains Testing = Yes`
                `Update related record field: Inventories`
                `Disposed? = true`
                `Date of Disposal = Now()`
                `Quantity Disposed = inventory_record__vr.quantity_remaining__v`

## Required Permissions

The following permissions are required to work with the Retains Testing feature:

### Design Data Admin Permission Set

* *SDSA* Object
    * Text Creation Exclusion (Read, Edit)

### LIMS Retains User Permission Set

* *Retain Inventory* Object Type
    * Read, Create, Edit
* *Retain Inventory Summary* Object Type
    * Read, Create, Edit
* *Retain Lab Sample* Object Type
    * Read, Create, Edit
* *Retain Testing Spec Execution* Object Type
    * Read, Create, Edit
* *Retain Testing Input*
    * Read, Create, Edit

### Groups

* Add LIMS Retains Specialist security profile to:
    * All LIMS Users
    * LIMS Sample Coordinators 