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://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252FTtCluBiyLJDpe3gAltqo%252F0.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=f46cc05c&sv=1)
In the dataflow, we have used an Excel Workbook Source object to extract data from the source files, and a 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://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252FNnUsXVBgqaVUhnSnq7gy%252F1.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=be280616&sv=1)
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://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252FdylKkjR1phIbopROpS1V%252F2.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=7b105ceb&sv=1)
We have incorporated this dataflow into our workflow by using the Run Dataflow object. You will notice that the FilePath variable is visible in the object layout.
![](https://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252FlmNEH1DvfmlQbdfx6umI%252F3.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=357b95bd&sv=1)
Go to the Resources section in the Toolbox and drag and drop the Context Information object onto the workflow designer.
![](https://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252FuYOaTxQIim8J8lf8IilC%252F4.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=e2b1c907&sv=1)
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://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252FR3eCwktNkMD6iiQu2WMk%252F5.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=c3e7c1c7&sv=1)
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://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252F6WtF2lyHHUUq2DuRxBtK%252F6.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=36017db9&sv=1)
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/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252FBMAmvlx0Rtd7y9nITYh8%252F7.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=284d2a51&sv=1)
Further, we have specified a directory where the files will be dropped.
![](https://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252Fs8SUSUes4EtX4wMANzI0%252F8.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=ca7bd1b6&sv=1)
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://documentation.astera.com/~gitbook/image?url=https%3A%2F%2F3891069449-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F28dJIkGHacXhBlux3efx%252Fuploads%252FpS25K8NbkjAIMhpra3dW%252F9.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=89faf1db&sv=1)
This concludes using the Context Information object in Astera.
Last updated