Use the SetEnvironmentVariable component
Create or update an environment variable as part of an automation Workflow by using the SetEnvironmentVariable component in RPA Desktop Design Studio. These variables persist across activities and can be retrieved later using GetEnvironmentVariable.
Before you begin
Role required: none
About this task
You can configure the properties for the SetEnvironmentVariable component. For more information about these properties, see Properties of the Environment components.
Procedure
-
In the Toolbox pane, navigate to Utilities > Environment.
-
Drag the SetEnvironmentVariable component to the Design surface.
-
To configure the input fields, see Configure port properties.
-
Connect the data and control ports of the SetEnvironmentVariable component to the corresponding ports of the other components as described in the following table.
Port type Purpose of connection Mandatory? Data In (variable) Takes the environment variable name from a previously executed component. Yes Data In (value) Takes the environment variable value from a previously executed component. Yes Control In Connects to the Control Out port of one or more components. Yes Control Out Connects to the Control In port of another component or the default end component. No. Connecting the port is optional. -
To test the component, under the DESIGN tab, click Run.
GetEnvironmentVariable component
You want your robot to process files and save logs to different folders depending on whether it's running in Development or Production mode.
-
At the start of the automation, use SetEnvironmentVariable to define the following variables:
ENV_MODE = DevelopmentLOG_PATH = C:\RPA\Dev\LogsThis variable defines if robot is running in the development mode, where to store the log files.
[Omitted image "set-env-var-dev-rpa.png"] Alt text: SetEnvironmentVariable with development environment details.
-
Later in the workflow, when saving log files, use GetEnvironmentVariable to retrieve the value of
LOG_PATH.The robot dynamically stores the log files as per the value in the
LOG_PATHvariable. -
In production, simply update the environment variable setup to:
ENV_MODE = ProductionLOG_PATH = C:\RPA\Prod\Logs[Omitted image "set-env-var-prod-rpa.png"] Alt text: SetEnvironmentVariable with production environment details.
The robot now logs to the production folder automatically, because it reads the
LOG_PATHvalue from the environment variable.
Parent Topic:Environment
---
title: Use the SetEnvironmentVariable component
description: Create or update an environment variable as part of an automation Workflow by using the SetEnvironmentVariable component in RPA Desktop Design Studio. These variables persist across activities and can be retrieved later using GetEnvironmentVariable.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/integrate-applications/use-environment-setenvvariable.html
release: australia
topic_type: task
last_updated: "2026-09-10"
reading_time_minutes: 1
breadcrumb: [Environment, Utilities, Automation components, RPA Desktop Design Studio, Robotic Process Automation \(RPA\) Hub, Workflow Data Fabric]
---
# Use the SetEnvironmentVariable component
Create or update an environment variable as part of an automation Workflow by using the SetEnvironmentVariable component in RPA Desktop Design Studio. These variables persist across activities and can be retrieved later using GetEnvironmentVariable.
## Before you begin
Role required: none
## About this task
You can configure the properties for the SetEnvironmentVariable component. For more information about these properties, see [Properties of the Environment components](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/integrate-applications/util-environment-prop.md).
## Procedure
1. In the Toolbox pane, navigate to **Utilities** > **Environment**.
2. Drag the SetEnvironmentVariable component to the Design surface.
3. To configure the input fields, see [Configure port properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/integrate-applications/configure-input-port-properties.md).
4. Connect the data and control ports of the SetEnvironmentVariable component to the corresponding ports of the other components as described in the following table.
|Port type|Purpose of connection|Mandatory?|
|---------|---------------------|----------|
|Data In \(variable\)|Takes the environment variable name from a previously executed component.|Yes|
|Data In \(value\)|Takes the environment variable value from a previously executed component.|Yes|
|Control In|Connects to the Control Out port of one or more components.|Yes|
|Control Out|Connects to the Control In port of another component or the default end component.|No. Connecting the port is optional.|
5. To test the component, under the **DESIGN** tab, click **Run**.
## GetEnvironmentVariable component
You want your robot to process files and save logs to different folders depending on whether it's running in Development or Production mode.
1. At the start of the automation, use SetEnvironmentVariable to define the following variables:
- `ENV_MODE = Development`
- `LOG_PATH = C:\RPA\Dev\Logs`
This variable defines if robot is running in the development mode, where to store the log files.
\[Omitted image "set-env-var-dev-rpa.png"\] Alt text: SetEnvironmentVariable with development environment details.
2. Later in the workflow, when saving log files, use **GetEnvironmentVariable** to retrieve the value of `LOG_PATH`.
The robot dynamically stores the log files as per the value in the `LOG_PATH` variable.
3. In production, simply update the environment variable setup to:
- `ENV_MODE = Production`
- `LOG_PATH = C:\RPA\Prod\Logs`
\[Omitted image "set-env-var-prod-rpa.png"\] Alt text: SetEnvironmentVariable with production environment details.
The robot now logs to the production folder automatically, because it reads the `LOG_PATH` value from the environment variable.
**Parent Topic:**[Environment](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/integrate-applications/environment-utility.md)
| title | Use the SetEnvironmentVariable component |
| description | Create or update an environment variable as part of an automation Workflow by using the SetEnvironmentVariable component in RPA Desktop Design Studio. These variables persist across activities and can be retrieved later using GetEnvironmentVariable. |
| locale | en-US |
| canonical_url | https://www.servicenow.com/docs/r/australia/integrate-applications/use-environment-setenvvariable.html |
| release | australia |
| topic_type | task |
| last_updated | 2026-09-10 |
| reading_time_minutes | 1 |
| breadcrumb | EnvironmentUtilitiesAutomation componentsRPA Desktop Design StudioRobotic Process Automation \(RPA\) HubWorkflow Data Fabric |