# Defining context variables

## Procedure

1. Click the [+] button to add lines in the table.

   ![Context view.](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio-context-view-for-job-or-route.png)
2. Click in the Name field and enter the name of the variable you are creating.

   Name the first variable host for this example.
3. From the Type list, select the type of the variable.

   Information noteWarning: If you change the type of a variable that has already a value, the value will be cleared and you need to set it again.
4. If needed, click in the Comment field and enter a comment to describe the variable.
5. Click in the value field for each context environment and enter the variable value.

   For different variable types, the value field appears slightly different when you click in it and functions differently:
   | Type | Value field |
   | --- | --- |
   | String (default type) | Editable text field |
   | Boolean | Drop-down list box with two options:<br>true and<br>false |
   | Character,<br>Double,<br>Integer,<br>Long,<br>Short,<br>Object,<br>BigDecimal | Editable text field |
   | Date | Editable text field, with a button to open<br>theSelect Date & Time dialog<br>box. |
   | File | Editable text field, with a button to open the<br>Open dialog box for file<br>selection. |
   | Directory | Editable text field, with a button to open the<br>Browse for Folder dialog box for<br>folder selection. |
   | List of Value | Editable text field, with a button to open the<br>Configure Values dialog box for<br>list creation and configuration. |
   | Password | Editable text field; text entered appears<br>encrypted. |
   | Resource | Editable text field, with a button to open the<br>Select a Resource dialog box for<br>you to select a resource defined under<br>Resources in the Repository.<br><br><br>For more information, see [Using resources in Jobs](https://help.qlik.com/talend/en-US/studio-user-guide/8.0-R2024-10/using-resources-in-jobs "You can create resources in Talend Studio and use them in your Jobs for file handling. This way, when exporting your Jobs, for example, you can pack the resource files as Job dependencies and deploy your Jobs without having to copy the files to the target system."). |
6. Optional: To display a prompt for the variable value and to edit it when running your Job or Route in a context environment, select the Enable prompt check box.

   This check box is applied globally to all context environments and the context variable name is used as the prompt label.
7. Repeat the above steps to define all the variables for the different contexts.
   * port, type String,
   * database, type String,
   * username, type String,
   * password, type Password,
   * table, type String.

## Results

All the variables created and their values under different context environments are displayed in the table and are ready for use in your Job. You can further edit the variables in this view if needed.

You can also add a built-in context variable to the Repository to make it reusable across different Jobs. For more information, see [Adding a built-in context variable to the Repository](https://help.qlik.com/talend/en-US/studio-user-guide/8.0/adding-built-in-context-variable-to-repository).

Related topics:

* [Defining context variables from the Component view](https://help.qlik.com/talend/en-US/studio-user-guide/8.0/defining-variables-from-component-view)
* [Centralizing context variables in the Repository](https://help.qlik.com/talend/en-US/studio-user-guide/8.0/centralizing-context-variables-in-repository)
* [Using variables in a Job or Route](https://help.qlik.com/talend/en-US/studio-user-guide/8.0/using-variables-in-job-or-route)
* [Running a Job or Route in a selected context environment](https://help.qlik.com/talend/en-US/studio-user-guide/8.0/running-job-or-route-in-selected-context)