cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get to list the jobs associated to an application?

former_member832484
Discoverer
0 Kudos

I am really new to Redwood. I need to somehow read an application and track down the jobs associated with it. So far, I have done just the script below but do not know the object and method to get the jobs in it. The flow needs to be from application>jobs instead of jobs>application as that would give a problem as thousands of jobs are being checked whether it satisfies the application condition

--------------------------

Application app=jcsSession.getApplicationByName("Testing");

Accepted Solutions (1)

Accepted Solutions (1)

h_carpenter
Active Contributor
0 Kudos

Hi Ballgantung Kurikuntao,

The call jcsSession.getApplicationByName("Testing").getChildJobDefinitions() will return an iterator over all job definitions in your application and with job definitions, you can get the jobs.

There are examples in the documentation, search for iterator and you should find examples how to "iterate" over the job definitions and get the jobs.

Regards,

HP

former_member832484
Discoverer
0 Kudos

Hi, I have done this. But through this iteration, I get some duplication of the job definitions in the application. Am I doing the iteration right?



-----------------------------------


{

for (Iterator it = jcsSession.getApplicationByName("Testing").getChildJobDefinitions(); it.hasNext();)

     {

       JobDefinition jobdef=(JobDefinition) it.next();

       jcsOut.println("Job Definiton --- "  +jobdef.getName()+ "   "+jobdef.getCreationTime());

               

     }

     

}

gmblom
Active Contributor
0 Kudos

Hello,

You only need the Master version definitions:

{

  for (Iterator it = jcsSession.getApplicationByName("Testing").getChildJobDefinitions(); it.hasNext();)

  {

    JobDefinition jobdef=(JobDefinition) it.next();

    if (jobdef.isMasterVersion())

    {

       jcsOut.println("Job Definiton --- "  +jobdef.getName()+ "   "+jobdef.getCreationTime());

    }

}

Regards Gerben

former_member832484
Discoverer
0 Kudos

Thanks G.Blom for your helpful help. It works. Do you know where I can read on how to get the jobs from the job definition obtained from the lines above?. I only know through query as below which I dont want to use earlier as it would check on all jobs.

----------------

String query="select Job.* from Job where Name<>'System'";

for (iterator it=jcsSession.executeObjectQuery(query,null); it.hasNext();

----------------

Is there an object and method like  " jcsSession.getApplicationByName("Testing").getChildJobDefinitions()  "  but to get the jobs in job definition instead of getting job definitions in an application

Answers (1)

Answers (1)

gmblom
Active Contributor
0 Kudos

Hello,

A probably easier approach is to create a Job filter to select the jobs you want. For instance, the 'where job is part of Application' is one of the filter items.

This filter then can potentially be used in Report etc.

Regards Gerben