{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":3950,"path":"build-workflows/workflow-studio/archive-process-executions.md","title":"Archive process contexts","bundle":null,"doc_type":null,"release":"australia","body":"\n# Archive process contexts\n\nImprove database query performance by archiving unneeded records for playbooks that are in a **Complete**, **Error**, or **Cancelled** state.\n\n## Before you begin\n\nRole required: admin or playbook.admin\n\n## About this task\n\nDepending on how many playbooks you have run, you may have hundreds or thousands of records in your database that aren't used anymore. Reduce the number of records that your database queries have to search through by archiving the records for playbooks that are in a **Complete**, **Error**, or **Cancelled** state.\n\nBy default, context records are automatically archived for process executions that are:\n\n-   In **Complete**, **Skipped**, or **Cancelled** state\n-   For a playbook that hasn’t been edited within 14 days.\n\n    **Note:** You can adjust the number of days. To learn more about configuring archive settings, see [Configure archive settings for process contexts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/config-archive-settings-process-contexts.md).\n\n\nIf you don't want context records to automatically be archived, see [Turn off automated archiving](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/turn-off-automated-archiving.md).\n\nContexts for process executions that are in an **Error** state must be archived manually.\n\n**Note:** If you no longer need logs for a process execution that ended in an error, archive the context records.\n\nWhen you archive context records for a process execution, the following records are compressed into a single JSON record:\n\n-   Element mapping \\[`sys_element_mapping`\\]\n-   Context log \\[`sys_pd_context_logs`\\]\n-   Variable value \\[`sys_variable_value`\\]\n-   Activity context \\[`sys_pd_activity_context`\\]\n-   Stage context \\[`sys_pd_lane_context`\\]\n\nThe JSON record can be viewed, but not edited. To learn more about viewing the JSON record for archived context data, see [View archived process contexts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/view-archived-process-executions.md).\n\n**Warning:** Archiving cannot be undone. If you need context logs or reports that use these records, don’t archive. If automated archiving creates report problems, turn off the feature. To learn how to turn off automated archiving, see [Turn off automated archiving](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/turn-off-automated-archiving.md).\n\nAgents can still open playbooks to see historical data, such as why a playbook was canceled or who an activity was assigned to.\n\nFlow context \\(`sys_flow_context`\\) records are also deleted automatically 2 weeks after completion. For more information about flow data retention, see [Flow execution details retention](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/flow-reporting.md).\n\n## Procedure\n\n1.  Manually archive context records for a process execution\n2.  Navigate to **All**, and enter **sys\\_pd\\_context.list** in the Filter field to open the \\[sys\\_pd\\_context\\] table.\n\n3.  Select the check boxes next to the executions that you want to archive context records for.\n\n4.  In the upper right corner, select **Archive Process Contexts** from the action menu.\n\n5.  Confirm that you want to archive the process contexts.\n\n\n## Result\n\nThe context records are archived for your selected process executions.\n\nIf you have a large number of context records to archive, records are archived in limited batches on an hourly basis, to avoid slowing down the instance.\n\n## Archive context records for an execution\n\n\\[Omitted image \"archive-process-context.gif\"\\] Alt text: Archive context records for a process execution\n\n## What to do next\n\nConfigure the form layout for process executions so that you can see the archived data. To learn more about configuring the form layout for a process execution, see [View archived process contexts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/view-archived-process-executions.md).\n\n-   **[Configure archive settings for process contexts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/config-archive-settings-process-contexts.md)**  \nChange the default settings for the automated archiving feature for process contexts.\n-   **[Turn off automated archiving](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/turn-off-automated-archiving.md)**  \nTurn off the automatic archiving of context records for your complete and cancelled playbooks.\n-   **[View archived process contexts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/view-archived-process-executions.md)**  \nConfigure the form layout for a process execution so that you can see the JSON record for archived context records.\n\n**Parent Topic:**[Administering Playbooks](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/administering-process-automation-designer.md)\n\n"}}