# Context Information

The *Context Information* object in Astera provides a set of context information parameters that take their values at the 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**

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FTtCluBiyLJDpe3gAltqo%2F0.png?alt=media)

In the dataflow, we have used an [*Excel Workbook Source*](https://documentation.astera.com/astera-data-stack-v9/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-v9/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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FNnUsXVBgqaVUhnSnq7gy%2F1.png?alt=media)

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FdylKkjR1phIbopROpS1V%2F2.png?alt=media)

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

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FlmNEH1DvfmlQbdfx6umI%2F3.png?alt=media)

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

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FuYOaTxQIim8J8lf8IilC%2F4.png?alt=media)

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FR3eCwktNkMD6iiQu2WMk%2F5.png?alt=media)

* *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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2F6WtF2lyHHUUq2DuRxBtK%2F6.png?alt=media)

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-v9/project-management/job-scheduling/scheduling-jobs-on-the-server)*.*

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FBMAmvlx0Rtd7y9nITYh8%2F7.png?alt=media)

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

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fs8SUSUes4EtX4wMANzI0%2F8.png?alt=media)

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FpS25K8NbkjAIMhpra3dW%2F9.png?alt=media)

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