Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
anna_t1
Contributor III
Contributor III

How to force return code at the end of the job

Hello,

How can I force my main job to return error code in the last line when running from script? Because in Studio, we have something like "[duration: hh:mm:ss exitcode=0]" ath the end of the main job.

Is this possible to achieve without manipulating logs or stats catcher?

I think this is requested when other apps need the exit code from our job, right?

Please find attach my main job with pre and postjobs. You can see that I changed a bit stats and log catcher, but I was wondering if I had to check something like "if job=current job name then paragraph and write code", in tMap component after StatsCatcher.

We should have an easier way to jsut return the exit code or not, at the end ...

2 Replies
Fabio_Caimi
Contributor II
Contributor II

Hi,

in case your job "01. Prepare sites" matches tRunJob_1...

After tPostJob_parent you could add a tJava component which gets its return code

(Integer)globalMap.getOrDefault("tRunJob_1_CHILD_RETURN_CODE", 0)

you can do the same for the other tRunJobs.

 

In case of errors (CHILD_RETURN_CODE > 0) in one of your tRunJobs, you may also decide to end your main job with a custom error code adding a tDie.

 

To recap:

tPostJob -> tJava -> if -> tDie

 

 

 

anna_t1
Contributor III
Contributor III
Author

@Fabio Caimi​, @Xiaodi Shi​  My main job has 4 child jobs without "Die on Child Error" checked, and since they all have pre and postjob components as well, is this correct (PFA image)?

 

Or is it sufficient to have all checked with "Die on Error" (except child2) and let my 2nd LogCatcher catch twarns and Tdies?

 

In my case, trunJob2 is the only one I need to uncheck that option because I want to be able to distinguish between a warning and failure, which I do inside it. This I have to keep and it works fine.

But for the remaining ones I'm not sure, if the parent will behave as expected: exit = 1 when one of the remaining child fails and want to make sure that each child don't trigger next trunjob on failure.