Skip to Content
0

Change of a parameter of a scheduled System_Mail_Send

Mar 14 at 02:17 PM

78

avatar image

Hello,

I have a lot of jobchains with some steps and at the end of the jobchains there is a job System_Mail_Send with certain information e.g mail address abc.xyz@company.com

Now I want to Change the mail address in all jobchains.

I wrote a script:

import java.util.Iterator;
import com.redwood.scheduler.api.model.*;
import com.redwood.scheduler.api.model.enumeration.*;

{  
  String strSuchString = "abc.xyz@company.com";  
  Iterator itJobParam = jcsSession.executeObjectQuery("SELECT * from JobChainCallInExpressionParameter jcp WHERE jcp.Expression = ?", new Object[]{strSuchString});  
  if(!itJobParam.hasNext())  
  {  
    jcsErr.println("No jobs found");  
    jcsJobContext.setReturnCode(101);  
    return;
  }  
  while(itJobParam.hasNext())  
  {  
    JobChainCallInExpressionParameter jcp = (JobChainCallInExpressionParameter) itJobParam.next();    
    jcp.setExpression("aaa.bbb@ycompany.com");  
  }    

  if(p_TestRun.equals("N"))  
  {  
    jcsSession.persist(); 
  }
}

Unfortunatelly it works only if the jobchain isn't scheduled.

How I have to change the script for changing scheduled jobchains too. The jobchains are not running at the moment of the change, they are only scheduled for the future.

Thanks and Best regards

Dana Ullrich

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
G.M. Blom Apr 11 at 09:44 PM
0

You can call job.updateJob() on the top level job of the scheduled jobs that use these definitions.

Regards Gerben

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hello Gerben,

how can I get the according job?
From JobChainCallInExpressionParameter I only can get the JobDefinition

( JobChainCallInExpressionParameter.getJobChainCall().getJobChainStep().getJobChain().getJobDefinition()

)


Best regards

Dana

0

Yes correct. That will give you the Chain that is updated.

Now query for all active Jobs for that Chain. Something like 'select j.* from Job j, JobDefinition jd where jd.MasterJobDefinition = ? and j.JobDefinition = jd.UniqueId and j.Status in (a list of possible active states)'

Now for each, look up the top level process:

Job getTopLevelJob(Job j)
{
  Job parent = j;
  while (parent.getParentJob() != null)
  {
    parent = parent.getParentJob();
  }
  return parent;
}

and perform the j.updateJob();

Dont forget to persist at the end :)

Regards Gerben

0

Hello Gerben,

thank you very much!
With your hints I could finish my job and it works very well!

Best regards
Dana

0