cancel
Showing results for 
Search instead for 
Did you mean: 

Rerun scheduled reports as user

omacoder
Active Contributor
0 Kudos

Our WIPS and DSL servers were down for approx 3 hours. During that time, a lot of scheduled jobs failed.

As an administrator, I can find all the jobs that failed in Instance Manager. I can also re-run them from here, but it will run the job as the "Administrator".

Instead, I need to re-run the job as the user who scheduled the job, as to consider their business and data security profiles.

Can I achieve this?

Accepted Solutions (1)

Accepted Solutions (1)

Joe_Peters
Active Contributor
0 Kudos

Extending from my comment above...

Date exDate;
calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 1);
exDate = calendar.getTime();
...
Integer iOwner = (Integer) oI.properties().getProperty("SI_OWNERID").getValue();

oSched.getSchedulingInfo().setScheduleOnBehalfOf(iOwner);
oSched.getSchedulingInfo().setRightNow(true);
oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);

while(oSched.getSchedulingInfo().getDependencies().size() > 0)
    oSched.getSchedulingInfo().getDependencies().remove(0);

oSched.getSchedulingInfo().setEndDate(exDate);
oInfoStore.schedule(oScheds);
oI.deleteNow();

This is just a snippet of a much larger program. I initially get the failed instances with:

IInfoObjects oInfoObjects = oInfoStore.query("select top 10000 * from ci_infoobjects where si_schedule_status = 3   and si_update_ts between  " + timeCondition + "  and si_name not like '%trigger%' and si_kind != 'scopebatch'"); 

"timeCondition" is calculated based on the current time and date, and will look something like "'2018.09.26 01.00.00' and '2018.09.26 08.00.00'"

I simply iterate over the results:

    Integer total = oInfoObjects.size(); 
    for(int x = 0;x < total;x++)
    {
        IInfoObject oI = (IInfoObject)oInfoObjects.get(x);

Note that I'm referencing both oI and oSched. I have logic that performs another CMS query on the same object and retrieves it into oSched. I don't remember why I did this, and it seems unnecessary.

    IInfoObjects oScheds = oInfoStore.query("select * from ci_infoobjects,ci_appobjects where si_id = " + oI.getID());

    if(oScheds.size() == 0)
    {
        System.out.println("Could not get existing schedules.");
        continue;
    }

    IInfoObject oSched = (IInfoObject) oScheds.get(0);

Answers (1)

Answers (1)

former_member182521
Active Contributor

Schedule on behalf as other user as shown in the image.

omacoder
Active Contributor
0 Kudos

This tells me how to schedule a job...?

This doesn't tell me how to re-run hundreds of jobs for hundreds of different users automatically. Help?

former_member182521
Active Contributor
0 Kudos

You may need to go for a custom SDK code as I dont see any alternative solutions. Check for Idea place entry for this requirement, if not please create a one.Idea place


Joe_Peters
Active Contributor

It can be done with the SDK. This is a portion of the program I use to reschedule a batch of failed reports: I just call setScheduleOnBehalfOf(), passing the instance's owner ID. I also set the job to run "Now", remove any events, and set the end date to tomorrow.

Date exDate;
calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 1);
exDate = calendar.getTime();
...
Integer iOwner = (Integer) oI.properties().getProperty("SI_OWNERID").getValue();

oSched.getSchedulingInfo().setScheduleOnBehalfOf(iOwner);
oSched.getSchedulingInfo().setRightNow(true);
oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);

while(oSched.getSchedulingInfo().getDependencies().size() > 0)
    oSched.getSchedulingInfo().getDependencies().remove(0);

oSched.getSchedulingInfo().setEndDate(exDate);
oInfoStore.schedule(oScheds);
oI.deleteNow();
omacoder
Active Contributor
0 Kudos
omacoder
Active Contributor
0 Kudos

THANK YOU, Joe!! What do you load oI object with?

Can you convert this to an answer?