# Post-Install Script Overview

Purpose: Upon installation or upgrade of the managed package, the system executes a post-install script that handles various configuration, migration, and data transformation tasks. The logic is conditional based on the existing org configuration and the version being upgraded from.

***

### 🧩 Steps Performed by the Script

## S-Docs

{% stepper %}
{% step %}
**Key Initialization**

* **Condition:** Always run (if values are not already set).
* **Details:**
  * `SDocsPrivateSettings__c.Key__c` is initialized with a generated key.
  * `SDocsPrivateSettings__c.ESign_Encryption_Key__c` is initialized for eSignature encryption.
* **Purpose:** Ensures cryptographic keys are available for secure operations.
  {% endstep %}

{% step %}
**Migration: `GD_Link__c` → `Document_Link__c`**

* **Condition:** Run if upgrading from version **prior to 4.557**.
* **Process:** A batch job migrates existing values from `SDoc__c.GD_Link__c` to the newer `SDoc__c.Document_Link__c` field.
* **Purpose:** Field schema evolution to support new document link architecture.
  {% endstep %}

{% step %}
**DOCX File Name Decryption and Escaping**

* **Condition:** Run if upgrading from version **prior to 4.557**.
* **Process:** A batch job decrypts and character-escapes legacy DOCX file names.
* **Purpose:** Ensures compatibility with current file handling logic.
  {% endstep %}

{% step %}
**Feature Job Scheduling**

* **Condition:** Only if the job is not already scheduled.
* **Details:** Schedules the `FeatureUpdateSchedulable` Apex job.
* **Purpose:** Enables feature-related background updates or checks.
  {% endstep %}

{% step %}
**Migration: `Email_SendTo__c` → `Email_Send_To_Long__c`**

* **Condition:** Run if upgrading from version **prior to 6.0**.
* **Process:** Migrates values from the shorter text field on `SDTemplate__c` to a longer one to accommodate expanded email data.
* **Purpose:** Prevents data truncation issues and supports future enhancements.
  {% endstep %}

{% step %}
**Action Record Cloning**

* **Condition:** Run if upgrading from version **between 7.2 and 7.3**.
* **Process:** Clones `Action__c` object records into the new `SDAction__c` object.
* **Purpose:** Supports migration to updated data schema.
  {% endstep %}

{% step %}
**Log Record Cloning**

* **Condition:** Run if upgrading from version **between 5.2 and 8.2**.
* **Process:** Clones `Log__c` object records into the new `SDLog__c` object.
* **Purpose:** Supports migration to updated data schema.
  {% endstep %}

{% step %}
**File Metadata Mapping**

* **Condition:** Run if upgrading from version **prior to 9.0**.
* **Process:** A batch job assigns:
  * `SDoc__c.File_ID__c` → `ContentDocument.Id`
  * `SDoc__c.File_Version_ID__c` → `ContentVersion.Id`
* **Purpose:** Supports transition to Salesforce Content (Files) model.
  {% endstep %}

{% step %}
**Auto-create conflict removal**

* **Condition:** Run if upgrading from version **prior to 11.0**.
* **Process:** Query on `SDTemplate__c` finds templates with both `SDOC__Create_Attachment__c` and `SDOC__Create_File__c` set to `TRUE` and disables `SDOC__Create_Attachment__c`
* **Purpose:** Allow Files to generate via legacy methods.
  {% endstep %}
  {% endstepper %}

## S-Sign

{% stepper %}
{% step %}
**In-flight notifications**

* **Condition:** Always run (if values are not already set).
* **Details:** Evaluates `SSEnvelope_Document__c` and `SSEnvelope__c`, sets `Sends_Notifications__c` on `SSEnvelope__c` to `TRUE` for qualifying records.
* **Purpose:** Sets new field used in new Batch Notifications Job for existing requests.
  {% endstep %}
  {% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/sdocs/administration/landing-page-for-admin/install-configure/post-install-script-overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
