Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Dynamic context variable value based on input row

Hi!

 

I want to give context variable value during runtime ,in tmap code will be like :

row5.context.myvalue.

 

Is this possible?

 

Please help.

 

Thanks!

Labels (1)
7 Replies
Anonymous
Not applicable
Author

Hi,

 

   You can pass the value to context variables during run time. Please refer below post.

 

https://community.talend.com/t5/Design-and-Development/resolved-Passing-variable-context-value-from-...

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

Hi Nikhi,

 

I want to pass the value at job level while
manually running it , that too with in row1.name Instead of this u want to
give row1.context.name where I can give context value at run time.

 

It is throwing an error now , is there any other way that i could achieve this.

 

can you pls help @nthampi .

 

Thanks,

Alekya

Anonymous
Not applicable
Author

Hi,

 

As per the @nthampi, yes we can pass context variable at run time. But you are stating as you are getting an error, please let us know what the actual error you are getting and what did you tried. If you let us know the details of your requirement, it will be easy to community members to give you the correct solution.

Anonymous
Not applicable
Author

Hi,

i want to pass value like below :

row1.context.variable --- in tmap..

i have elaborated below :

https://community.talend.com/t5/Design-and-Development/Dynamic-Field-assignment-through-context-vari...

Thanks,
Alekya
Anonymous
Not applicable
Author

Hi Alekya,

 

    You are trying to define the schema at run time. Since Talend uses schema based processing, you will have to write custom code to parse the data if your column details are changing at runtime. In this case, you will have to define a metadata in advance and based on the combination, you will have to dynamically build them using java codes.

 

    I would approach this in slighlt different way. I would try to use file formats which are flexible in nature like JSON or XML and will define all the columns as tags in the definition. So if a column is not there, corresponding tag will not be there. But still we will be able to parse the data easily since our definition includes all the tags in advance.

 

     Could you please try this method? 

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

 

 

Anonymous
Not applicable
Author

Hi Nikhil,

can u please elaborate ur solution ,i haven't worked much with json files.

Thanks,
Alekya
Anonymous
Not applicable
Author

Hi,

 

     The JSON record looks like below. So you need to create a schema which will include all combination of columns.

 

    {"name":"John", "age":31, "city":"New York", "zipcode":"12345"}

 

     Once this schema is established, you can send the data with subset of it where some records will not have zipcode, some other without age etc.

 

      End of day, even though your schema is fluctuating, you will have have an idea of the list of columns which can come to target database. So if you establish all these columns inside a JSON or XML, you can handle the data processing easily.

 

https://www.w3schools.com/js/js_json_intro.asp

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂