Talend tContextLoad

In Talend, you can use the tContextLoad to load the value from a properties file to the context variables. The concept is the same with Java properties file. It is extremely handy when it comes to the following situation:

  1. Username and password
  2. Configurable flag
  3. File path to read and write data

 

Below is an example how you can utilise tContextLoad to save Username and password for Salesforce.
A developer needs to create a three Talend jobs to upsert the data into Salesforce account, contact and opportunity. Instead of keeping Salesforce credential in these jobs separately, you can use tContextLoad to store in one properties file.

Step 1: Create the properties file

Create a configuration folder in your Talend folder and name it as “conf”.
Inside the properties file, put in the username, password and security token:
sf_username=insert your Salesforce Username here
sf_password=insert your Salesforce Password here
sf_token=insert your Salesforce Security Token here

* the variable name need to be similar in your Talend context variable name.

Step 2: Get properties file data

Now what we need to do is get back the data from the properties. How we can do it? Actually, we can use tFileInputProperties component to load all the data from the .properties file.
Below is the setting in the tFileInputProperties component:
File Format: Choose the right file format that you want to get.
File Name:  Specific where and what is the file name.

Step 3: Set the Context value

First, you need to create the context variables which match the properties file name.
At the end, use the tContextLoad to set all the value from the properties file to the context variables during run time. Below is the final result in your Talend process.

Note: This is just an example of how tContextLoad works. Storing username and password in a clear text file is not recommended in an actual production environment.

Get in touch today to see how WDCi can help your business.