Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
StefanBackstrand
Partner - Specialist
Partner - Specialist

Getting value from a global variable in a component field

I'm populating a global variable (since I cannot seem to get passing contexts between jobs working) and then want to read this value from another job - namely in tFixedFlowInput (for testing). But how do I reference it in the field?

I'm trying this and similar, but it's not working. Ideas? If I do tSetGlobalVar in THE SAME job, it works, but not in another job. I'm also obviously using tRunJob and OnOk to make sure that job gets run first.

(String)globalMap.get("myKey")

Labels (1)
1 Solution

Accepted Solutions
Xiaodi_Shi
Support
Support

Hello,

Talend joblets factorizes recurrent processing or complex transformation steps to ease the reading of a complex Job. Joblets can be reused in different Jobs or several times in the same Job.

Here are online documentations about:

https://help.talend.com/en-US/studio-user-guide/8.0-R2024-07/creating-joblet-from-job

https://help.talend.com/en-US/studio-user-guide/8.0-R2024-07/using-joblet-in-job

Best regards

Sabrina

 

View solution in original post

5 Replies
AChardon
Contributor II
Contributor II

Hello Stefan,

I’m pretty sure you can’t do that with a global variable. There are several ways to transfer data between jobs; could you describe your needs

Regards,

Arnaud

StefanBackstrand
Partner - Specialist
Partner - Specialist
Author

Thanks, it seems you're right - it doesn't seem possible to use global variables over several different jobs. The are "only" global within the job/joblet.

I want to pass pieces of data between jobs, in an effort to contain logic in smaller jobs that then gets referenced in several other jobs. An example is to have a small job who's only task is to call a REST API to get an API token that will be used in multiple other places in the pipeline/jobs.

I seem to have solved it by using tBufferOutput, which was good because it allows me to pass on a whole schema/map of values, instead of just single explicitly named values (like context variables).

StefanBackstrand
Partner - Specialist
Partner - Specialist
Author

I'm just now exploring Joblets as an option. It's interesting that I've only just glaced over that job type before. Thoughts on using that instead?

Xiaodi_Shi
Support
Support

Hello,

Talend joblets factorizes recurrent processing or complex transformation steps to ease the reading of a complex Job. Joblets can be reused in different Jobs or several times in the same Job.

Here are online documentations about:

https://help.talend.com/en-US/studio-user-guide/8.0-R2024-07/creating-joblet-from-job

https://help.talend.com/en-US/studio-user-guide/8.0-R2024-07/using-joblet-in-job

Best regards

Sabrina

 

AChardon
Contributor II
Contributor II

maybe  you can use the bufferoutput, do a contextload after, and load the data by the context way  in other job, by selecting Transmit whole context, or Context Param in runJob component.

or globalVar  with ContextParam but you will have to map them all.

Not sure if i am very clear 😄