# Context Information

The *Context Information* object in Astera provides a set of context information parameters that take their values at runtime of a dataflow or workflow. These parameters include several details related to the job taking place and the server on which it is being run, such as *ServerName*, *JobId*, *UserName*, and *DroppedFilePath*, among others.

### Use Case

In this use case, we will automate the process of writing a fictitious organization’s customer data, which is currently available in an Excel format, to a database table. The source data is stored in multiple Excel files, and each of these files will be dropped into a particular folder. Our goal is to design a process where customer data is extracted from every file that is dropped into the folder, and then written to a destination table without any manual intervention. For this, we will be using the *DroppedFilePath* parameter in the *Context Information* object, in conjunction with the *When File is Dropped* option in the Astera *Job Scheduler.*

### Using the Context Information Object in Astera&#x20;

We have already designed a dataflow to create the process of writing data to a destination table, and we will orchestrate this process for automation in a workflow.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FG0uw1bbBuMQenMubPXlZ%2F01-context-information-dataflow.PNG?alt=media\&token=20cf2b2c-8e1e-451c-8781-a8df2ed529bf)

In the dataflow, we have used an [*Excel Workbook Source* ](https://documentation.astera.com/astera-data-stack-v10/dataflows/sources/excel-workbook-source)object to extract data from the source files, and a [*Database Table Destination*](https://documentation.astera.com/astera-data-stack-v10/dataflows/destinations/database-table-destination) object to write this data to a database table. A *Variables* object has been used to create a variable that will provide source file paths to the *Excel Workbook Source* object.

On the *Variables Properties* screen of the *Variables* object, you will see that we have created an input variable, *FilePath*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FL2vlDg5BFCdpGu7hkYvf%2F02-context-information-variable-filepath.PNG?alt=media\&token=d1c4f13c-fd27-4062-bb0d-7e8d38ea07e1)

We have used this variable as an input parameter for the *FilePath* section in the *Config Parameters* screen of the *Excel Workbook Source* object.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FyZhUuHZDYMwxVeX3jOnR%2F03-context-information-excel-config-parameters.PNG?alt=media\&token=3333f872-22ce-41cd-a268-1c61a24fc8b4)

We have incorporated this dataflow into our workflow by using the [*Run Dataflow* ](https://documentation.astera.com/astera-data-stack-v10/workflows/run-dataflow)object. You will notice that the *FilePath* variable is visible in the object layout.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FLaK2bt78qHzL0o8h70x8%2F04-context-information-run-dataflow.PNG?alt=media\&token=f556faa3-a466-4e76-b5f9-ed414dfcf763)

Go to the Resources section in the Toolbox, and drag-and-drop the *Context Information* object onto the workflow designer.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FKe6gNfYFJjEN1zG4S9X3%2F05-context-information-workflow.PNG?alt=media\&token=2b227e3d-9a33-4c4e-9be7-2e1961d0f208)

In the object layout, you can see all of the context information parameters that are available. If you wish to see their data types, right-click on the object header and select *Properties* from the context menu.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FxSFeYGxjOymEO41gsPDV%2F06-context-information-properties.PNG?alt=media\&token=447ea006-3836-4517-9883-6205ff41d88e)

* *Name*: Name of the workflow. For example, Workflow1.wf
* *JobId*: ID of the job assigned by the server
* *ScheduledJobId*: ID of the job associated with a schedule in case of scheduled running on a server
* *ServerName*: Name of the server running the workflow
* *UserName*: User account that runs the workflow
* *DroppedFilePath*: Path to the file being dropped, in case of a scheduled job of type ‘When File is Dropped’

As mentioned earlier, all of these parameters take their values at run-time.

In this case, we require the *DroppedFilePath* parameter’s value to be fed to the source object in our dataflow. Map this parameter from the *Context Information* object to the *FilePath* variable that is visible under the *Input* node of the *Run Dataflow* object.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FZHIqLFJ2G9WR6NsavQyU%2F07-context-information-worflow.PNG?alt=media\&token=07e29f4d-e308-464a-84ed-7c94f4439116)

Now, all that is left is to schedule this job to run whenever a source file is dropped into a specified folder. For this, we have selected the *When File is Dropped* option under the *Frequency* section of the [*Job Scheduler*](https://documentation.astera.com/astera-data-stack-v10/project-management-and-scheduling/job-scheduling/scheduling-jobs-on-the-server)*.*

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FGr4CDgmnoPD6vyKuCsTh%2F13-context-information-job-scheduler.PNG?alt=media\&token=b4f85dbd-e43c-4245-865e-2d00ebd7e5db)

Further, we have specified a directory where the files will be dropped.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F5EJSpbFiRV7QVuuYDcMK%2F14-context-info-job-scheduler-file-drop.png?alt=media\&token=3af1f6e3-4200-4f7a-87e9-d60bfaa6d32f)

Once we have created this schedule, every delimited file dropped into this folder will automatically be written to the destination table. Here is a look at the destination table after we have added one source file to the folder.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FsXehoo1NmjguMRHz9nai%2F15-context-information-destination-table.PNG?alt=media\&token=bd2d047e-c5a7-4bad-80ff-2f5dc9e728c1)

This concludes using the *Context Information* object in Astera.
