# Config.xlsx — Three-Sheet Reference

UiPath REFramework projects use `Data/Config.xlsx` with **three sheets**: Settings, Constants, and Assets. The scaffold script copies the template with framework defaults. When generating workflows, **add all project-specific keys to the correct sheet**.

## How InitAllSettings.xaml Processes Config.xlsx

1. Reads **Settings** + **Constants** sheets → stores each row's Name/Value directly into the `Config` dictionary
2. Reads **Assets** sheet → for each row, calls `GetRobotAsset` with the `Asset` column value from Orchestrator → stores the result in `Config` under the `Name` column key
3. **Assets always overwrite** Settings/Constants if the same Name exists (by design — Orchestrator is the source of truth for environment-specific values)

All three sheets merge into a single `Config` dictionary — workflows access any key the same way: `Config("KeyName").ToString`.

## Sheet 1: Settings (project identity & credential references)

**Purpose:** Values that identify the project within Orchestrator and reference credential assets by name. These are local to the Excel file, don't require API calls, and rarely change once deployed.

| Column | Description |
|---|---|
| Name | Config dictionary key |
| Value | Local value (string, number, or boolean) |
| Description | Human-readable explanation |

### Framework defaults (auto-generated by scaffold)

| Name | Value | Description |
|---|---|---|
| `OrchestratorQueueName` | `MyQueue` | Queue name — must match Orchestrator |
| `OrchestratorQueueFolder` | `Shared` | Orchestrator folder containing the queue |
| `logF_BusinessProcessName` | `MyProcess` | Process name for logging |
| `ProcessesToKill` | `msedge;EXCEL` | Semicolon-separated process names killed at Init and End. Used by `KillAllProcesses.xaml` |

### Project-specific keys (you add these)

| Name | Value | Description |
|---|---|---|
| `WebApp_CredentialAssetName` | `WebApp_Credential` | Orchestrator Credential asset name for WebApp login |
| `API_CredentialAssetName` | `API_Credential` | Orchestrator Credential asset name for API auth |
| `HRPortal_CredentialAsset` | `HRPortal_Credential` | Orchestrator Credential asset name for HR Portal |

**Why credentials stay in Settings:** `CredentialAssetName` entries are just name strings passed to `GetRobotCredential` inside the workflow that needs them. Putting them in Assets would trigger an unnecessary `GetRobotAsset` call just to fetch a string that never changes per environment. The actual secret retrieval happens via `GetRobotCredential` at the point of use.

## Sheet 2: Constants (immutable framework values)

**Purpose:** Values that never change regardless of environment (dev/staging/prod). Framework behavior, log message templates, retry configuration.

| Column | Description |
|---|---|
| Name | Config dictionary key |
| Value | Immutable value |
| Description | Human-readable explanation |

### Framework defaults (auto-generated by scaffold)

| Name | Value | Description |
|---|---|---|
| `MaxRetryNumber` | `0` | Must be 0 for Orchestrator queues; >0 for local retry |
| `MaxConsecutiveSystemExceptions` | `0` | Consecutive system exceptions before stopping (0 = disabled) |
| `ExScreenshotsFolderPath` | `Exceptions_Screenshots` | Screenshot save path (relative or absolute) |
| `RetryNumberGetTransactionItem` | `2` | Retries for GetTransactionItem activity |
| `RetryNumberSetTransactionStatus` | `2` | Retries for SetTransactionStatus activity |
| `ShouldMarkJobAsFaulted` | `False` | Mark job as Faulted on init error or max consecutive exceptions |
| `LogMessage_GetTransactionData` | `Processing Transaction Number: ` | Log message prefix |
| `LogMessage_GetTransactionDataError` | `Error getting transaction data...` | Log message prefix |
| `LogMessage_Success` | `Transaction Successful.` | Log message |
| `LogMessage_BusinessRuleException` | `Business rule exception.` | Log message |
| `LogMessage_ApplicationException` | `System exception.` | Log message |
| `ExceptionMessage_ConsecutiveErrors` | `The maximum number of...` | Error message |

### Project-specific constants (add when needed)

| Name | Value | Description |
|---|---|---|
| `MaxLoginAttempts` | `3` | Fixed retry limit for app login |
| `TransactionTimeoutMinutes` | `10` | Hard timeout per transaction |

**Rule of thumb:** If the value would be identical in dev, staging, and production, it belongs in Constants.

## Sheet 3: Assets (Orchestrator-managed, environment-specific)

**Purpose:** Values fetched from Orchestrator Assets at runtime. Use for anything that changes between environments, is shared across multiple automations, or that admins need to update without redeploying.

| Column | Description |
|---|---|
| Name | Config dictionary key (how workflows reference it) |
| Asset | Orchestrator Asset name (what InitAllSettings fetches) |
| OrchestratorAssetFolder | Orchestrator folder containing the asset (blank for default) |
| Description | Note: "Assets will always overwrite other config" |

### Project-specific keys (you add these)

| Name | Asset | OrchestratorAssetFolder | Description |
|---|---|---|---|
| `WebApp_Url` | `WebApp_ApplicationUrl` | `Shared` | the target web application login URL |
| `WebApp_BaseUrl` | `WebApp_BaseUrl` | `Shared` | WebApp base URL for dynamic page construction |
| `WebApp_CreateTaskUrl` | `WebApp_CreateTaskUrl` | `Shared` | Direct URL to create task page |
| `SHA1Online_Url` | `SHA1Online_Url` | `Shared` | SHA1 Online tool URL |
| `API_BaseUrl` | `API_BaseEndpoint` | `Shared` | REST API base endpoint |
| `DownloadFolder` | `Process_DownloadFolder` | | Download folder path (varies per machine/env) |
| `ReportOutputPath` | `Process_ReportOutputPath` | | Report output path |
| `EmailRecipients` | `Process_EmailRecipients` | `Shared` | Notification recipients (shared across projects) |

### What belongs in Assets

- **URLs and endpoints** — application URLs, API base URLs, page-specific URLs (different per environment)
- **File/network paths** — download folders, output paths, shared drives (different per machine/env)
- **Shared configuration** — values used by multiple automations (email recipients, department codes)
- **Admin-tunable values** — timeouts, thresholds, feature flags that admins adjust without redeploying
- **Environment-specific identifiers** — server names, database connection strings (name only, not credentials)

### What does NOT belong in Assets

- **Credentials** — use `GetRobotCredential` directly (Credential asset type, not Text asset)
- **Credential asset names** — just strings, keep in Settings to avoid unnecessary API calls
- **Framework constants** — retry counts, log messages (never change per environment)
- **Queue/process identity** — `OrchestratorQueueName`, `logF_BusinessProcessName` (project-bound)

## How Config Is Used in Workflows

**Retrieval:** `Config("KeyName").ToString` — Config values are `Object` type, always call `.ToString` for string operations. Works identically regardless of which sheet the key came from.

**Passed via arguments:** Main.xaml reads Config, passes values to sub-workflows:
```
InvokeWorkflow: WebApp_Launch.xaml
  in_strUrl = Config("WebApp_Url").ToString
  in_strCredentialAssetName = Config("WebApp_CredentialAssetName").ToString
```

**Dynamic URLs:** Concatenate base URL with runtime values:
```
strTargetUrl = String.Format("{0}/work-item/{1}", Config("WebApp_BaseUrl").ToString, strWIID)
```

## Key Naming Convention

| Pattern | Example | Sheet | Use for |
|---|---|---|---|
| `AppName_Url` | `WebApp_Url` | Assets | App login/home URL |
| `AppName_BaseUrl` | `WebApp_BaseUrl` | Assets | Base URL for dynamic page construction |
| `AppName_PageUrl` | `WebApp_CreateTaskUrl` | Assets | Direct URL to specific page |
| `API_BaseUrl` | `API_BaseUrl` | Assets | REST API base endpoint |
| `AppName_CredentialAssetName` | `WebApp_CredentialAssetName` | Settings | Orchestrator Credential asset name |
| `OrchestratorQueueName` | `OrchestratorQueueName` | Settings | Queue identity |
| `MaxRetryNumber` | `MaxRetryNumber` | Constants | Framework retry config |

## Required Config.xlsx Keys Output

After generating workflows, **always list the Config.xlsx keys the user needs to add, grouped by sheet**:

```
Required Config.xlsx entries:

  Settings sheet:
    WebApp_CredentialAssetName        — Orchestrator Credential asset for WebApp login

  Assets sheet:
    WebApp_Url                        — the target web application login URL (Asset: WebApp_ApplicationUrl)
    WebApp_BaseUrl                    — WebApp base URL for dynamic pages (Asset: WebApp_BaseUrl)
    SHA1Online_Url                  — SHA1 Online tool URL (Asset: SHA1Online_Url)

  Constants sheet:
    (none — framework defaults sufficient)
```

This helps the user set up both Config.xlsx and the corresponding Orchestrator Assets before running the automation.

## Decision Flowchart

```
Is this a credential (password, API key, secret, token)?
  → YES: Don't put in Config.xlsx at all. Use GetRobotCredential directly.

Is this the NAME of a credential asset?
  → YES: Settings sheet (just a string, no API call needed)

Does this value change between dev/staging/prod environments?
  → YES: Assets sheet (fetched from Orchestrator)

Is this value shared across multiple automations?
  → YES: Assets sheet (single source of truth in Orchestrator)

Could an admin need to change this without redeploying?
  → YES: Assets sheet

Is this a framework constant (retry count, log message, path template)?
  → YES: Constants sheet

Is this project identity (queue name, process name)?
  → YES: Settings sheet
```
