I have a Talend job that takes in 3 salesforce table name strings given in an input csv file and queries them for one column, "name". I created a tJavaRow component where I am able to loop through all table names in the input file and query them like so: "Select Name from " + TableName + " limit 10"
However, I want to be able to get all the columns of the table and query them each. Basically, I want the query to look like this:
"Select " + fieldName + "from " + TableName + " limit 10"
I'm having trouble figuring out how to get all the column names of the salesforce table from the input file. Is there any possible way to do this? Below you will find my job design and tJavaRow code screenshots. Thanks in advance to anyone who can help!
tJavaRow Component Code
it depend - what format of Your csv file (may require different methods)
for example - for read all column names from header line, read only 1 row and split it
for not guess and produce ideas, could You attach example - what Your source?
Thanks for your reply. Actually, the column names are not in the excel file. My goal is to get the column names dynamically from the salesforce schema that exists in the talend Metadata panel. So based on the table name, which does exist in the csv file, I want to get the column name from the schema. Here is the excel file formatted with Table name, schema, and last run time.
The salesforce schema exists in the metadata section, which exists in the repository panel in Talend. Here is the screenshot:
Metadata Salesforce section
Is there a way I can get the column name of the table from the csv file? I want to be able to access that salesforce metadata from the tJavaRow component. Thanks!
agree with @TRF - better to check Salesforce API for this
Talend metadata not available for loop with code or components (similar as Information Schema is databases where You can select all columns, types and etc)
Thanks for your helpful tips! I'm just having trouble understanding how to integrate the Salesforce Metadata API. Since I am writing my Java code within the tJavaRow component, is it even possible to write the java code to implement the Salesforce Metadata API? To clarify again what I am trying to do, I am given 4 table names within a csv file that exist in the Salesforce schema located in the Metadata section of the Talend Repositories Panel, shown below.
So say the current table being processed by the tJavaRow code is "Account". I want to be able to get all of its columns that exist within it, but the code has to be written inside the tJavaRow component. To clarify again, here is the tJavaRow component code.
My question now is, is it even possible to write code for the Salesforce Metadata API within this component? I need to be able to make that SOQL query have dynamic field names, so there must be a way to access it given the table name from the csv file, which in this case is stored in the TabName1 variable.
I know that my request sounds very complex and that I'm repeating myself, but I am new to Talend and Salesforce and have a tight deadline to complete this goal. Any help on how to implement the Salesforce API to get the column names given the table name from csv file by writing code in the tJavaRow component would be greatly appreciated. Thanks again everyone for your continued help!
Sorry no time to go in details now but Salesforce metadata API should be accessed using tRest family components, not tJava family. 1st try to get documentation from Salesforce regarding this API with Java example, then translate these examples to Talend (or maybe an other guy have the response ready)