cancel
Showing results for 
Search instead for 
Did you mean: 

Set job on hold by script

Former Member
0 Kudos

Hello,

I want to set a certain cycle job on hold and release it by script because the action should take place in the night (no office hours).

Is this possible? I cannot use the Jobgroup-End-Option because I don't know before when the maintenance will be started.

I think to schedule a job for the hold-time, which has a parameter "Job". The parameter will be filled by choosing a Jobdefinition from the "Query filter All Jobdefinitons".

How I get the Job I want to hold from the Jobdefinition by script?

...

JobDefinition jd = jcsSession.getJobDefinitionByName(strJobName);

Long ID = jd.getUniqueId();

??? how I get the Job j from the UniqueId  ???

j.hold();

Thanks for your help!

Best regards,

Dana Ullrich

Accepted Solutions (1)

Accepted Solutions (1)

h_carpenter
Active Contributor
0 Kudos

Hi Dana,

How about select Job.* from Job where Job.JobDefinition = (select JobDefinition.UniqueId from JobDefinition where JobDefinition.Name = 'MyJobDefinition') order by Job.JobId DESC;

Job.* from Job where Job.Status = JobStatus.Held and Job.JobDefinition = (select JobDefinition.UniqueId from JobDefinition where JobDefinition.Name = 'MyJobDefinition');

Not sure about JobStatus.Held constant, please check in the API-DOCS ...

Throw that first query, as we did last time, to executeObjectQuery ... the first job will be the job of that job definition with the highest job id, I assume this is the job you want ... if there is another job scheduled, you will have to make sure you get the right one. Do you have any other means of identifying the job, schedule start time, for example ?

HP

Message was edited by: h. Carpenter I originally sent this from my smartphone and got a few things wrong, sorry.

Answers (1)

Answers (1)

nanda_kumar21
Active Contributor
0 Kudos

Hi Dana,

I went through the API documentation and wasn't able to find a method for the interface JobDefinition that directly returns the object "job". This i find odd, because we can select Monitor Related Jobs option from the context menu and check entire job history across different states, so one would assume there should be a direct way to obtain the scheduled job as an object.

Anyway, if the scheduled job is related to the Job Definition, then it should be shown in the related object list in the details, in that case getJobDefinitionRelatedObject() may return the object "job" for the scheduled job.

This is just my assumption.

Thanks

Nanda